diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6b7b74c5..da59f99e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.3.0" + ".": "0.4.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a0aad226..31dad448 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 115 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome/metronome-f12f505faf40d5f25d74c0b5a417e2b36c7f3f9621a0e23acd3d6ec4c615443e.yml -openapi_spec_hash: 5c1f13896608a69feebd8855703b76df -config_hash: 6bd82f310398d5d47bcfeb8d7ed150b3 +configured_endpoints: 116 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome/metronome-52a719b7812239e8efa99324ecfd233d2c211759de37967748b72e8f090e9ed6.yml +openapi_spec_hash: 0052973e6013937f6fe75cad02c056d2 +config_hash: 82cceaeee1ce998c3e1aa0e082a4629e diff --git a/CHANGELOG.md b/CHANGELOG.md index db36ccd4..bb057967 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## 0.4.0 (2026-06-23) + +Full Changelog: [v0.3.0...v0.4.0](https://github.com/Metronome-Industries/metronome-java/compare/v0.3.0...v0.4.0) + +### Features + +* [🪿] Remove `allow-subscriptions-custom-billing-anchor` feature flag ([397ef78](https://github.com/Metronome-Industries/metronome-java/commit/397ef78e3dabd3606699d9cff3d182aa543c1159)) +* Add alert specifiers to for `low_remaining_contract_credit_and_commit_balance_reached` threshold notification creation payload ([39cbc8b](https://github.com/Metronome-Industries/metronome-java/commit/39cbc8b5794429e286a361a639681e6e40c3390b)) +* Add any_commit_and_credit_ids to override specifier fields ([46e9238](https://github.com/Metronome-Industries/metronome-java/commit/46e923808fc09864121bd3d81bbc45fd9bc67aad)) +* add getSubscriptionSeatsHistory to Node SDK ([0abdb68](https://github.com/Metronome-Industries/metronome-java/commit/0abdb689b432de9ad25b410f9ef590ef513b67a8)) +* Add notification_metadata to four API endpoints (Anthropic-only) ([9d6f8cc](https://github.com/Metronome-Industries/metronome-java/commit/9d6f8cc2505b368e02391165a8be7f364d806182)) +* added created by to commits ([c930b59](https://github.com/Metronome-Industries/metronome-java/commit/c930b592310e556dbf3b24dafc054390e2b237d2)) +* createdBy description specifies excluding system created commits ([f5ca585](https://github.com/Metronome-Industries/metronome-java/commit/f5ca585c93854409cc2c2ea9fcb96399ecfec82a)) +* daily recurrence frequency for recurring commits ([a59d59b](https://github.com/Metronome-Industries/metronome-java/commit/a59d59b8948dcf884b7e61362674aba565f53e56)) +* Docs: Update v1.yml ([47fbf41](https://github.com/Metronome-Industries/metronome-java/commit/47fbf416e9dbf1a3ca4164b5dcfb84ca830cadd5)) +* Revert "[pgs] Remove `allow-subscriptions-custom-billing-anchor` and proration rounding feature flags" ([d03dec2](https://github.com/Metronome-Industries/metronome-java/commit/d03dec261d259798d7e487304ef7ea0fcf9c1c91)) +* Revert "Revert "[pgs] Remove `allow-subscriptions-custom-billing-anchor` and proration rounding feature flags"" ([f943c66](https://github.com/Metronome-Industries/metronome-java/commit/f943c6600f55b3116242045dc853debd40498cfd)) +* skip seat IDs from balances ([940923e](https://github.com/Metronome-Industries/metronome-java/commit/940923e3267160004a17410cf9ddf4fc59b7b240)) +* Update copy ([29736d9](https://github.com/Metronome-Industries/metronome-java/commit/29736d9b3ae735221ae6b9e9a42728bf48b37eb4)) + + +### Chores + +* (internal) Add description for threshold balance specifiers fields ([c62a15d](https://github.com/Metronome-Industries/metronome-java/commit/c62a15dc3f07b0bf5a930119c5b29e410476104f)) + + +### Documentation + +* add RPS limit and batch recommendation to addRate endpoint ([a1b6cdb](https://github.com/Metronome-Industries/metronome-java/commit/a1b6cdb286db1ad27be80929f228a82ac5e2c3ba)) + ## 0.3.0 (2026-05-29) Full Changelog: [v0.2.0...v0.3.0](https://github.com/Metronome-Industries/metronome-java/compare/v0.2.0...v0.3.0) diff --git a/README.md b/README.md index c574abaa..bd8cfa00 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.metronome.api/metronome-java)](https://central.sonatype.com/artifact/com.metronome.api/metronome-java/0.3.0) -[![javadoc](https://javadoc.io/badge2/com.metronome.api/metronome-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.metronome.api/metronome-java/0.3.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.metronome.api/metronome-java)](https://central.sonatype.com/artifact/com.metronome.api/metronome-java/0.4.0) +[![javadoc](https://javadoc.io/badge2/com.metronome.api/metronome-java/0.4.0/javadoc.svg)](https://javadoc.io/doc/com.metronome.api/metronome-java/0.4.0) @@ -20,7 +20,7 @@ Use the Metronome MCP Server to enable AI assistants to interact with this API, -The REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.metronome.api/metronome-java/0.3.0). +The REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.metronome.api/metronome-java/0.4.0). @@ -31,7 +31,7 @@ The REST API documentation can be found on [docs.metronome.com](https://docs.met ### Gradle ```kotlin -implementation("com.metronome.api:metronome-java:0.3.0") +implementation("com.metronome.api:metronome-java:0.4.0") ``` ### Maven @@ -40,7 +40,7 @@ implementation("com.metronome.api:metronome-java:0.3.0") com.metronome.api metronome-java - 0.3.0 + 0.4.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 38cffb59..259c3d94 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.metronome.api" - version = "0.3.0" // x-release-please-version + version = "0.4.0" // x-release-please-version } subprojects { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Commit.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Commit.kt index b636d72d..6025cb1a 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Commit.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Commit.kt @@ -47,6 +47,7 @@ private constructor( private val archivedAt: JsonField, private val balance: JsonField, private val contract: JsonField, + private val createdBy: JsonField, private val customFields: JsonField, private val description: JsonField, private val hierarchyConfiguration: JsonField, @@ -94,6 +95,7 @@ private constructor( archivedAt: JsonField = JsonMissing.of(), @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), @JsonProperty("contract") @ExcludeMissing contract: JsonField = JsonMissing.of(), + @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -153,6 +155,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -268,6 +271,15 @@ private constructor( */ fun contract(): Optional = contract.getOptional("contract") + /** + * The actor who created this commit. Omitted for system-generated commits such as recurring + * commits, rollover commits, and threshold commits. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -515,6 +527,13 @@ private constructor( */ @JsonProperty("contract") @ExcludeMissing fun _contract(): JsonField = contract + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + /** * Returns the raw JSON value of [customFields]. * @@ -717,6 +736,7 @@ private constructor( private var archivedAt: JsonField = JsonMissing.of() private var balance: JsonField = JsonMissing.of() private var contract: JsonField = JsonMissing.of() + private var createdBy: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var hierarchyConfiguration: JsonField = @@ -752,6 +772,7 @@ private constructor( archivedAt = commit.archivedAt balance = commit.balance contract = commit.contract + createdBy = commit.createdBy customFields = commit.customFields description = commit.description hierarchyConfiguration = commit.hierarchyConfiguration @@ -972,6 +993,21 @@ private constructor( */ fun contract(contract: JsonField) = apply { this.contract = contract } + /** + * The actor who created this commit. Omitted for system-generated commits such as recurring + * commits, rollover commits, and threshold commits. + */ + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -1446,6 +1482,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -1495,6 +1532,7 @@ private constructor( archivedAt() balance() contract().ifPresent { it.validate() } + createdBy() customFields().ifPresent { it.validate() } description() hierarchyConfiguration().ifPresent { it.validate() } @@ -1543,6 +1581,7 @@ private constructor( (if (archivedAt.asKnown().isPresent) 1 else 0) + (if (balance.asKnown().isPresent) 1 else 0) + (contract.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -10752,6 +10791,7 @@ private constructor( archivedAt == other.archivedAt && balance == other.balance && contract == other.contract && + createdBy == other.createdBy && customFields == other.customFields && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && @@ -10787,6 +10827,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -10812,5 +10853,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Commit{id=$id, createdAt=$createdAt, product=$product, type=$type, accessSchedule=$accessSchedule, amount=$amount, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceContract=$invoiceContract, invoiceSchedule=$invoiceSchedule, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCommitId=$recurringCommitId, rolledOverFrom=$rolledOverFrom, rolloverFraction=$rolloverFraction, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, spendTrackerAttributes=$spendTrackerAttributes, subscriptionConfig=$subscriptionConfig, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" + "Commit{id=$id, createdAt=$createdAt, product=$product, type=$type, accessSchedule=$accessSchedule, amount=$amount, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, createdBy=$createdBy, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceContract=$invoiceContract, invoiceSchedule=$invoiceSchedule, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCommitId=$recurringCommitId, rolledOverFrom=$rolledOverFrom, rolloverFraction=$rolloverFraction, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, spendTrackerAttributes=$spendTrackerAttributes, subscriptionConfig=$subscriptionConfig, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" } diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractV2.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractV2.kt index 1a0823e2..6ceb299f 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractV2.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractV2.kt @@ -1864,6 +1864,7 @@ private constructor( private val archivedAt: JsonField, private val balance: JsonField, private val contract: JsonField, + private val createdBy: JsonField, private val customFields: JsonField, private val description: JsonField, private val hierarchyConfiguration: JsonField, @@ -1911,6 +1912,9 @@ private constructor( @JsonProperty("contract") @ExcludeMissing contract: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -1972,6 +1976,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -2076,6 +2081,15 @@ private constructor( */ fun contract(): Optional = contract.getOptional("contract") + /** + * The actor who created this commit. Omitted for system-generated commits such as recurring + * commits, rollover commits, and threshold commits. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -2308,6 +2322,13 @@ private constructor( */ @JsonProperty("contract") @ExcludeMissing fun _contract(): JsonField = contract + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + /** * Returns the raw JSON value of [customFields]. * @@ -2507,6 +2528,7 @@ private constructor( private var archivedAt: JsonField = JsonMissing.of() private var balance: JsonField = JsonMissing.of() private var contract: JsonField = JsonMissing.of() + private var createdBy: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var hierarchyConfiguration: JsonField = @@ -2541,6 +2563,7 @@ private constructor( archivedAt = commit.archivedAt balance = commit.balance contract = commit.contract + createdBy = commit.createdBy customFields = commit.customFields description = commit.description hierarchyConfiguration = commit.hierarchyConfiguration @@ -2754,6 +2777,21 @@ private constructor( */ fun contract(contract: JsonField) = apply { this.contract = contract } + /** + * The actor who created this commit. Omitted for system-generated commits such as + * recurring commits, rollover commits, and threshold commits. + */ + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -3231,6 +3269,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -3279,6 +3318,7 @@ private constructor( archivedAt() balance() contract().ifPresent { it.validate() } + createdBy() customFields().ifPresent { it.validate() } description() hierarchyConfiguration().ifPresent { it.validate() } @@ -3326,6 +3366,7 @@ private constructor( (if (archivedAt.asKnown().isPresent) 1 else 0) + (if (balance.asKnown().isPresent) 1 else 0) + (contract.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -12189,6 +12230,7 @@ private constructor( archivedAt == other.archivedAt && balance == other.balance && contract == other.contract && + createdBy == other.createdBy && customFields == other.customFields && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && @@ -12222,6 +12264,7 @@ private constructor( archivedAt, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -12246,7 +12289,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Commit{id=$id, createdAt=$createdAt, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceContract=$invoiceContract, invoiceSchedule=$invoiceSchedule, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCommitId=$recurringCommitId, rolledOverFrom=$rolledOverFrom, rolloverFraction=$rolloverFraction, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, spendTrackerAttributes=$spendTrackerAttributes, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "Commit{id=$id, createdAt=$createdAt, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, createdBy=$createdBy, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceContract=$invoiceContract, invoiceSchedule=$invoiceSchedule, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCommitId=$recurringCommitId, rolledOverFrom=$rolledOverFrom, rolloverFraction=$rolloverFraction, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, spendTrackerAttributes=$spendTrackerAttributes, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class Override @@ -12964,6 +13007,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -12976,6 +13020,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -12998,6 +13045,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -13008,6 +13056,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -13054,6 +13109,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -13148,6 +13213,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -13160,6 +13226,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -13171,6 +13239,32 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -13329,6 +13423,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -13357,6 +13452,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -13383,7 +13479,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -13796,6 +13893,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -13808,6 +13906,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -13822,7 +13921,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } class OverwriteRate @@ -16403,6 +16502,7 @@ private constructor( private val balance: JsonField, private val contract: JsonField, private val createdAt: JsonField, + private val createdBy: JsonField, private val customFields: JsonField, private val description: JsonField, private val hierarchyConfiguration: JsonField, @@ -16445,6 +16545,9 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -16491,6 +16594,7 @@ private constructor( balance, contract, createdAt, + createdBy, customFields, description, hierarchyConfiguration, @@ -16589,6 +16693,15 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("created_at") + /** + * The actor who created this credit. Omitted for system-generated credits such as recurring + * credits. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -16782,6 +16895,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + /** * Returns the raw JSON value of [customFields]. * @@ -16933,6 +17053,7 @@ private constructor( private var balance: JsonField = JsonMissing.of() private var contract: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var createdBy: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var hierarchyConfiguration: JsonField = @@ -16962,6 +17083,7 @@ private constructor( balance = credit.balance contract = credit.contract createdAt = credit.createdAt + createdBy = credit.createdBy customFields = credit.customFields description = credit.description hierarchyConfiguration = credit.hierarchyConfiguration @@ -17166,6 +17288,21 @@ private constructor( this.createdAt = createdAt } + /** + * The actor who created this credit. Omitted for system-generated credits such as + * recurring credits. + */ + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -17482,6 +17619,7 @@ private constructor( balance, contract, createdAt, + createdBy, customFields, description, hierarchyConfiguration, @@ -17525,6 +17663,7 @@ private constructor( balance() contract().ifPresent { it.validate() } createdAt() + createdBy() customFields().ifPresent { it.validate() } description() hierarchyConfiguration().ifPresent { it.validate() } @@ -17567,6 +17706,7 @@ private constructor( (if (balance.asKnown().isPresent) 1 else 0) + (contract.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -22778,6 +22918,7 @@ private constructor( balance == other.balance && contract == other.contract && createdAt == other.createdAt && + createdBy == other.createdBy && customFields == other.customFields && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && @@ -22806,6 +22947,7 @@ private constructor( balance, contract, createdAt, + createdBy, customFields, description, hierarchyConfiguration, @@ -22825,7 +22967,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Credit{id=$id, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, createdAt=$createdAt, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, recurringCreditId=$recurringCreditId, rolledOverFrom=$rolledOverFrom, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "Credit{id=$id, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, archivedAt=$archivedAt, balance=$balance, contract=$contract, createdAt=$createdAt, createdBy=$createdBy, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, recurringCreditId=$recurringCreditId, rolledOverFrom=$rolledOverFrom, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -25792,6 +25934,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -25846,6 +25989,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -25876,6 +26022,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -26018,6 +26165,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -26208,6 +26364,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -26299,6 +26465,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -26327,6 +26494,7 @@ private constructor( name = recurringCommit.name netsuiteSalesOrderId = recurringCommit.netsuiteSalesOrderId proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction specifiers = recurringCommit.specifiers.map { it.toMutableList() } @@ -26589,6 +26757,27 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -26729,6 +26918,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -26770,6 +26960,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -26810,6 +27001,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -28341,6 +28533,978 @@ private constructor( override fun toString() = value.toString() } + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice + + @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 [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply + } + + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -28371,6 +29535,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -28380,6 +29546,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -28398,6 +29565,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -28418,6 +29586,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -28436,6 +29605,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") } @@ -28527,6 +29697,7 @@ private constructor( name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -28553,6 +29724,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -28564,7 +29736,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class RecurringCredit @@ -28586,6 +29758,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -28637,6 +29810,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -28666,6 +29842,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -28800,6 +29977,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -28980,6 +30166,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -29070,6 +30266,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -29097,6 +30294,7 @@ private constructor( name = recurringCredit.name netsuiteSalesOrderId = recurringCredit.netsuiteSalesOrderId proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding recurrenceFrequency = recurringCredit.recurrenceFrequency rolloverFraction = recurringCredit.rolloverFraction specifiers = recurringCredit.specifiers.map { it.toMutableList() } @@ -29344,6 +30542,27 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -29483,6 +30702,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -29523,6 +30743,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -29562,6 +30783,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -30607,19 +31829,330 @@ private constructor( } /** - * Returns an immutable instance of [Contract]. + * Returns an immutable instance of [Contract]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Contract = + Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Contract = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Contract && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Contract{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + @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 [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Contract = - Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -30634,12 +32167,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Contract = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - id() + access().ifPresent { it.validate() } validated = true } @@ -30657,180 +32190,414 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is Contract && - id == other.id && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = "Contract{id=$id, additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - @JvmField val NONE = of("NONE") + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - @JvmField val FIRST = of("FIRST") + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - @JvmField val LAST = of("LAST") + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - _UNKNOWN, - } + fun validate(): Access = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN + decimalPlaces() + roundingMethod().validate() + validated = true } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - private var validated: Boolean = false + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Proration = apply { - if (validated) { - return@apply + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** @@ -30863,6 +32630,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -30872,6 +32641,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -30890,6 +32660,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -30910,6 +32681,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -30928,6 +32700,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") } @@ -31018,6 +32791,7 @@ private constructor( name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -31043,6 +32817,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -31054,7 +32829,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class ResellerRoyalty @@ -33949,6 +35724,7 @@ private constructor( private val startingAt: JsonField, private val subscriptionRate: JsonField, private val id: JsonField, + private val billingCycleConfig: JsonField, private val customFields: JsonField, private val description: JsonField, private val endingBefore: JsonField, @@ -33982,6 +35758,9 @@ private constructor( @ExcludeMissing subscriptionRate: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -34007,6 +35786,7 @@ private constructor( startingAt, subscriptionRate, id, + billingCycleConfig, customFields, description, endingBefore, @@ -34081,6 +35861,13 @@ private constructor( */ fun id(): Optional = id.getOptional("id") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -34195,6 +35982,16 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig + /** * Returns the raw JSON value of [customFields]. * @@ -34292,6 +36089,7 @@ private constructor( private var startingAt: JsonField? = null private var subscriptionRate: JsonField? = null private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var endingBefore: JsonField = JsonMissing.of() @@ -34310,6 +36108,7 @@ private constructor( startingAt = subscription.startingAt subscriptionRate = subscription.subscriptionRate id = subscription.id + billingCycleConfig = subscription.billingCycleConfig customFields = subscription.customFields description = subscription.description endingBefore = subscription.endingBefore @@ -34452,6 +36251,20 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) + + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -34578,6 +36391,7 @@ private constructor( checkRequired("startingAt", startingAt), checkRequired("subscriptionRate", subscriptionRate), id, + billingCycleConfig, customFields, description, endingBefore, @@ -34612,6 +36426,7 @@ private constructor( startingAt() subscriptionRate().validate() id() + billingCycleConfig().ifPresent { it.validate() } customFields().ifPresent { it.validate() } description() endingBefore() @@ -34645,6 +36460,7 @@ private constructor( (if (startingAt.asKnown().isPresent) 1 else 0) + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + @@ -35703,6 +37519,7 @@ private constructor( private constructor( private val invoiceBehavior: JsonField, private val isProrated: JsonField, + private val rounding: JsonField, private val additionalProperties: MutableMap, ) { @@ -35714,7 +37531,10 @@ private constructor( @JsonProperty("is_prorated") @ExcludeMissing isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is @@ -35730,6 +37550,12 @@ private constructor( */ fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + /** * Returns the raw JSON value of [invoiceBehavior]. * @@ -35750,6 +37576,16 @@ private constructor( @ExcludeMissing fun _isProrated(): JsonField = isProrated + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -35781,12 +37617,14 @@ private constructor( private var invoiceBehavior: JsonField? = null private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(proration: Proration) = apply { invoiceBehavior = proration.invoiceBehavior isProrated = proration.isProrated + rounding = proration.rounding additionalProperties = proration.additionalProperties.toMutableMap() } @@ -35817,6 +37655,17 @@ private constructor( this.isProrated = isProrated } + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -35856,6 +37705,7 @@ private constructor( Proration( checkRequired("invoiceBehavior", invoiceBehavior), checkRequired("isProrated", isProrated), + rounding, additionalProperties.toMutableMap(), ) } @@ -35879,6 +37729,7 @@ private constructor( invoiceBehavior().validate() isProrated() + rounding().ifPresent { it.validate() } validated = true } @@ -35899,7 +37750,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) class InvoiceBehavior @JsonCreator @@ -36046,6 +37898,395 @@ private constructor( override fun toString() = value.toString() } + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rounding]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36054,17 +38295,18 @@ private constructor( return other is Proration && invoiceBehavior == other.invoiceBehavior && isProrated == other.isProrated && + rounding == other.rounding && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" } /** @@ -37068,6 +39310,390 @@ private constructor( "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" } + class BillingCycleConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("anchor_date") + @ExcludeMissing + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") + @ExcludeMissing + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) + + /** + * The date this subscription's billing cycle is anchored to. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun anchorDate(): OffsetDateTime = anchorDate.getRequired("anchor_date") + + /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun invoicePlacement(): InvoicePlacement = + invoicePlacement.getRequired("invoice_placement") + + /** + * Returns the raw JSON value of [anchorDate]. + * + * Unlike [anchorDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("anchor_date") + @ExcludeMissing + fun _anchorDate(): JsonField = anchorDate + + /** + * Returns the raw JSON value of [invoicePlacement]. + * + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_placement") + @ExcludeMissing + fun _invoicePlacement(): JsonField = invoicePlacement + + @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 [BillingCycleConfig]. + * + * The following fields are required: + * ```java + * .anchorDate() + * .invoicePlacement() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleConfig]. */ + class Builder internal constructor() { + + private var anchorDate: JsonField? = null + private var invoicePlacement: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() + } + + /** The date this subscription's billing cycle is anchored to. */ + fun anchorDate(anchorDate: OffsetDateTime) = anchorDate(JsonField.of(anchorDate)) + + /** + * Sets [Builder.anchorDate] to an arbitrary JSON value. + * + * You should usually call [Builder.anchorDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate + } + + /** + * Controls whether this subscription consolidates onto usage invoices or gets its + * own scheduled invoice. + */ + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) + + /** + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingCycleConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .anchorDate() + * .invoicePlacement() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingCycleConfig = + BillingCycleConfig( + checkRequired("anchorDate", anchorDate), + checkRequired("invoicePlacement", invoicePlacement), + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BillingCycleConfig = apply { + if (validated) { + return@apply + } + + anchorDate() + invoicePlacement().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. + */ + class InvoicePlacement + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") + + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") + + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) + } + + /** An enum containing [InvoicePlacement]'s known values. */ + enum class Known { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, + } + + /** + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoicePlacement] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, + /** + * An enum member indicating that [InvoicePlacement] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE + else -> + throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoicePlacement = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoicePlacement && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(anchorDate, invoicePlacement, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" + } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ class CustomFields @JsonCreator @@ -37386,6 +40012,7 @@ private constructor( startingAt == other.startingAt && subscriptionRate == other.subscriptionRate && id == other.id && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && endingBefore == other.endingBefore && @@ -37405,6 +40032,7 @@ private constructor( startingAt, subscriptionRate, id, + billingCycleConfig, customFields, description, endingBefore, @@ -37418,7 +40046,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" + "Subscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractWithoutAmendments.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractWithoutAmendments.kt index 0459d9bb..7137fdcb 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractWithoutAmendments.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/ContractWithoutAmendments.kt @@ -2184,6 +2184,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -2238,6 +2239,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -2268,6 +2272,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -2410,6 +2415,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -2600,6 +2614,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -2691,6 +2715,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -2719,6 +2744,7 @@ private constructor( name = recurringCommit.name netsuiteSalesOrderId = recurringCommit.netsuiteSalesOrderId proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction specifiers = recurringCommit.specifiers.map { it.toMutableList() } @@ -2981,6 +3007,27 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -3121,6 +3168,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -3162,6 +3210,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -3202,6 +3251,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -4733,119 +4783,138 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -4858,12 +4927,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -4881,53 +4951,1014 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is RecurrenceFrequency && value == other.value - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode() = value.hashCode() + fun toBuilder() = Builder().from(this) - override fun toString() = value.toString() - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - return other is RecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - contract == other.contract && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + /** A builder for [Access]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { - Objects.hash( + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + contract == other.contract && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( id, accessAmount, commitDuration, @@ -4945,6 +5976,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -4956,7 +5988,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class RecurringCredit @@ -4978,6 +6010,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -5029,6 +6062,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -5058,6 +6094,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -5192,6 +6229,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -5372,6 +6418,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -5462,6 +6518,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -5489,6 +6546,7 @@ private constructor( name = recurringCredit.name netsuiteSalesOrderId = recurringCredit.netsuiteSalesOrderId proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding recurrenceFrequency = recurringCredit.recurrenceFrequency rolloverFraction = recurringCredit.rolloverFraction specifiers = recurringCredit.specifiers.map { it.toMutableList() } @@ -5736,6 +6794,27 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -5875,6 +6954,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -5915,6 +6995,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -5954,6 +7035,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -7121,60 +8203,210 @@ private constructor( LAST, FIRST_AND_LAST, /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + @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 [ProrationRounding]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -7187,12 +8419,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } validated = true } @@ -7210,19 +8442,415 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** @@ -7255,6 +8883,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -7264,6 +8894,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -7282,6 +8913,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -7302,6 +8934,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -7320,6 +8953,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") } @@ -7410,6 +9044,7 @@ private constructor( name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -7435,6 +9070,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -7446,7 +9082,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class ResellerRoyalty diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Credit.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Credit.kt index 5b3ad82d..230d27ad 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Credit.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Credit.kt @@ -44,6 +44,7 @@ private constructor( private val applicableProductTags: JsonField>, private val balance: JsonField, private val contract: JsonField, + private val createdBy: JsonField, private val customFields: JsonField, private val description: JsonField, private val hierarchyConfiguration: JsonField, @@ -80,6 +81,7 @@ private constructor( applicableProductTags: JsonField> = JsonMissing.of(), @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), @JsonProperty("contract") @ExcludeMissing contract: JsonField = JsonMissing.of(), + @JsonProperty("created_by") @ExcludeMissing createdBy: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -124,6 +126,7 @@ private constructor( applicableProductTags, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -208,6 +211,15 @@ private constructor( */ fun contract(): Optional = contract.getOptional("contract") + /** + * The actor who created this credit. Omitted for system-generated credits such as recurring + * credits. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -397,6 +409,13 @@ private constructor( */ @JsonProperty("contract") @ExcludeMissing fun _contract(): JsonField = contract + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + /** * Returns the raw JSON value of [customFields]. * @@ -557,6 +576,7 @@ private constructor( private var applicableProductTags: JsonField>? = null private var balance: JsonField = JsonMissing.of() private var contract: JsonField = JsonMissing.of() + private var createdBy: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var hierarchyConfiguration: JsonField = @@ -585,6 +605,7 @@ private constructor( applicableProductTags = credit.applicableProductTags.map { it.toMutableList() } balance = credit.balance contract = credit.contract + createdBy = credit.createdBy customFields = credit.customFields description = credit.description hierarchyConfiguration = credit.hierarchyConfiguration @@ -755,6 +776,21 @@ private constructor( */ fun contract(contract: JsonField) = apply { this.contract = contract } + /** + * The actor who created this credit. Omitted for system-generated credits such as recurring + * credits. + */ + fun createdBy(createdBy: String) = createdBy(JsonField.of(createdBy)) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -1095,6 +1131,7 @@ private constructor( (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -1137,6 +1174,7 @@ private constructor( applicableProductTags() balance() contract().ifPresent { it.validate() } + createdBy() customFields().ifPresent { it.validate() } description() hierarchyConfiguration().ifPresent { it.validate() } @@ -1178,6 +1216,7 @@ private constructor( (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + (if (balance.asKnown().isPresent) 1 else 0) + (contract.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdBy.asKnown().isPresent) 1 else 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6979,6 +7018,7 @@ private constructor( applicableProductTags == other.applicableProductTags && balance == other.balance && contract == other.contract && + createdBy == other.createdBy && customFields == other.customFields && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && @@ -7007,6 +7047,7 @@ private constructor( applicableProductTags, balance, contract, + createdBy, customFields, description, hierarchyConfiguration, @@ -7028,5 +7069,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Credit{id=$id, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, balance=$balance, contract=$contract, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCreditId=$recurringCreditId, rolledOverFrom=$rolledOverFrom, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" + "Credit{id=$id, product=$product, type=$type, accessSchedule=$accessSchedule, applicableContractIds=$applicableContractIds, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, balance=$balance, contract=$contract, createdBy=$createdBy, customFields=$customFields, description=$description, hierarchyConfiguration=$hierarchyConfiguration, ledger=$ledger, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, rateType=$rateType, recurringCreditId=$recurringCreditId, rolledOverFrom=$rolledOverFrom, salesforceOpportunityId=$salesforceOpportunityId, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" } diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Override.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Override.kt index 0b491dd1..88763d96 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Override.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Override.kt @@ -977,6 +977,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -989,6 +990,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -1011,6 +1015,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -1021,6 +1026,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1067,6 +1079,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -1153,6 +1175,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -1165,6 +1188,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -1175,6 +1200,32 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -1330,6 +1381,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -1357,6 +1409,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -1383,7 +1436,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -1788,6 +1842,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -1800,6 +1855,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -1814,7 +1870,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } class Product diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfiguration.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfiguration.kt index 63180241..83f6dfbf 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfiguration.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfiguration.kt @@ -127,6 +127,9 @@ private constructor( discountConfiguration.getOptional("discount_configuration") /** + * Determines which balances are excluded from remaining balance calculation for threshold + * billing. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -374,6 +377,10 @@ private constructor( this.discountConfiguration = discountConfiguration } + /** + * Determines which balances are excluded from remaining balance calculation for threshold + * billing. + */ fun thresholdBalanceSpecifiers( thresholdBalanceSpecifiers: List ) = thresholdBalanceSpecifiers(JsonField.of(thresholdBalanceSpecifiers)) @@ -1478,6 +1485,9 @@ private constructor( ) : this(exclude, mutableMapOf()) /** + * If any of the exclude specifier is met, the balance is not considered when evaluating + * threshold billing + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ @@ -1528,6 +1538,10 @@ private constructor( additionalProperties = thresholdBalanceSpecifier.additionalProperties.toMutableMap() } + /** + * If any of the exclude specifier is met, the balance is not considered when evaluating + * threshold billing + */ fun exclude(exclude: List) = exclude(JsonField.of(exclude)) /** diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfigurationV2.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfigurationV2.kt index 4c097953..1ea19817 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfigurationV2.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/PrepaidBalanceThresholdConfigurationV2.kt @@ -127,6 +127,9 @@ private constructor( discountConfiguration.getOptional("discount_configuration") /** + * Determines which balances are excluded from remaining balance calculation for threshold + * billing. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -374,6 +377,10 @@ private constructor( this.discountConfiguration = discountConfiguration } + /** + * Determines which balances are excluded from remaining balance calculation for threshold + * billing. + */ fun thresholdBalanceSpecifiers( thresholdBalanceSpecifiers: List ) = thresholdBalanceSpecifiers(JsonField.of(thresholdBalanceSpecifiers)) diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Subscription.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Subscription.kt index dc949ae1..aa34ec17 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/Subscription.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/Subscription.kt @@ -32,6 +32,7 @@ private constructor( private val startingAt: JsonField, private val subscriptionRate: JsonField, private val id: JsonField, + private val billingCycleConfig: JsonField, private val customFields: JsonField, private val description: JsonField, private val endingBefore: JsonField, @@ -65,6 +66,9 @@ private constructor( @ExcludeMissing subscriptionRate: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), @JsonProperty("custom_fields") @ExcludeMissing customFields: JsonField = JsonMissing.of(), @@ -90,6 +94,7 @@ private constructor( startingAt, subscriptionRate, id, + billingCycleConfig, customFields, description, endingBefore, @@ -164,6 +169,13 @@ private constructor( */ fun id(): Optional = id.getOptional("id") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") + /** * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * @@ -274,6 +286,16 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig + /** * Returns the raw JSON value of [customFields]. * @@ -367,6 +389,7 @@ private constructor( private var startingAt: JsonField? = null private var subscriptionRate: JsonField? = null private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() private var customFields: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var endingBefore: JsonField = JsonMissing.of() @@ -385,6 +408,7 @@ private constructor( startingAt = subscription.startingAt subscriptionRate = subscription.subscriptionRate id = subscription.id + billingCycleConfig = subscription.billingCycleConfig customFields = subscription.customFields description = subscription.description endingBefore = subscription.endingBefore @@ -526,6 +550,20 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) + + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) @@ -646,6 +684,7 @@ private constructor( checkRequired("startingAt", startingAt), checkRequired("subscriptionRate", subscriptionRate), id, + billingCycleConfig, customFields, description, endingBefore, @@ -679,6 +718,7 @@ private constructor( startingAt() subscriptionRate().validate() id() + billingCycleConfig().ifPresent { it.validate() } customFields().ifPresent { it.validate() } description() endingBefore() @@ -711,6 +751,7 @@ private constructor( (if (startingAt.asKnown().isPresent) 1 else 0) + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + (customFields.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + @@ -1753,6 +1794,7 @@ private constructor( private constructor( private val invoiceBehavior: JsonField, private val isProrated: JsonField, + private val rounding: JsonField, private val additionalProperties: MutableMap, ) { @@ -1764,7 +1806,10 @@ private constructor( @JsonProperty("is_prorated") @ExcludeMissing isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is @@ -1778,6 +1823,12 @@ private constructor( */ fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + /** * Returns the raw JSON value of [invoiceBehavior]. * @@ -1797,6 +1848,13 @@ private constructor( @ExcludeMissing fun _isProrated(): JsonField = isProrated + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rounding") @ExcludeMissing fun _rounding(): JsonField = rounding + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1828,12 +1886,14 @@ private constructor( private var invoiceBehavior: JsonField? = null private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(proration: Proration) = apply { invoiceBehavior = proration.invoiceBehavior isProrated = proration.isProrated + rounding = proration.rounding additionalProperties = proration.additionalProperties.toMutableMap() } @@ -1862,6 +1922,17 @@ private constructor( */ fun isProrated(isProrated: JsonField) = apply { this.isProrated = isProrated } + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1898,6 +1969,7 @@ private constructor( Proration( checkRequired("invoiceBehavior", invoiceBehavior), checkRequired("isProrated", isProrated), + rounding, additionalProperties.toMutableMap(), ) } @@ -1920,6 +1992,7 @@ private constructor( invoiceBehavior().validate() isProrated() + rounding().ifPresent { it.validate() } validated = true } @@ -1940,7 +2013,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) class InvoiceBehavior @JsonCreator @@ -2084,476 +2158,1443 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" - } - - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` must - * be provided with this option. - */ - class QuantityManagementMode - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val SEAT_BASED = of("SEAT_BASED") + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest 100 + * in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** An enum containing [QuantityManagementMode]'s known values. */ - enum class Known { - SEAT_BASED, - QUANTITY_ONLY, - } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * An enum containing [QuantityManagementMode]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [QuantityManagementMode] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEAT_BASED, - QUANTITY_ONLY, /** - * An enum member indicating that [QuantityManagementMode] was instantiated with an - * unknown value. + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. */ - _UNKNOWN, - } + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEAT_BASED -> Value.SEAT_BASED - QUANTITY_ONLY -> Value.QUANTITY_ONLY - else -> Value._UNKNOWN + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SEAT_BASED -> Known.SEAT_BASED - QUANTITY_ONLY -> Known.QUANTITY_ONLY - else -> - throw MetronomeInvalidDataException("Unknown QuantityManagementMode: $value") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): QuantityManagementMode = apply { - if (validated) { - return@apply + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() } - known() - validated = true - } + /** A builder for [Rounding]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - return other is QuantityManagementMode && value == other.value - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - override fun hashCode() = value.hashCode() + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - override fun toString() = value.toString() - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - class QuantitySchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val quantity: JsonField, - private val startingAt: JsonField, - private val endingBefore: JsonField, - private val additionalProperties: MutableMap, - ) { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonCreator + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException("Unknown RoundingMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" + } + + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` must + * be provided with this option. + */ + class QuantityManagementMode + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SEAT_BASED = of("SEAT_BASED") + + @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + + @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) + } + + /** An enum containing [QuantityManagementMode]'s known values. */ + enum class Known { + SEAT_BASED, + QUANTITY_ONLY, + } + + /** + * An enum containing [QuantityManagementMode]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [QuantityManagementMode] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SEAT_BASED, + QUANTITY_ONLY, + /** + * An enum member indicating that [QuantityManagementMode] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SEAT_BASED -> Value.SEAT_BASED + QUANTITY_ONLY -> Value.QUANTITY_ONLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SEAT_BASED -> Known.SEAT_BASED + QUANTITY_ONLY -> Known.QUANTITY_ONLY + else -> + throw MetronomeInvalidDataException("Unknown QuantityManagementMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): QuantityManagementMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QuantityManagementMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class QuantitySchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val quantity: JsonField, + private val startingAt: JsonField, + private val endingBefore: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + ) : this(quantity, startingAt, endingBefore, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + @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 [QuantitySchedule]. + * + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [QuantitySchedule]. */ + class Builder internal constructor() { + + private var quantity: JsonField? = null + private var startingAt: JsonField? = null + private var endingBefore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(quantitySchedule: QuantitySchedule) = apply { + quantity = quantitySchedule.quantity + startingAt = quantitySchedule.startingAt + endingBefore = quantitySchedule.endingBefore + additionalProperties = quantitySchedule.additionalProperties.toMutableMap() + } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [QuantitySchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): QuantitySchedule = + QuantitySchedule( + checkRequired("quantity", quantity), + checkRequired("startingAt", startingAt), + endingBefore, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): QuantitySchedule = apply { + if (validated) { + return@apply + } + + quantity() + startingAt() + endingBefore() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QuantitySchedule && + quantity == other.quantity && + startingAt == other.startingAt && + endingBefore == other.endingBefore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(quantity, startingAt, endingBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + } + + class SubscriptionRate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingFrequency: JsonField, + private val product: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + @JsonProperty("billing_frequency") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - ) : this(quantity, startingAt, endingBefore, mutableMapOf()) + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product") @ExcludeMissing product: JsonField = JsonMissing.of(), + ) : this(billingFrequency, product, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingFrequency(): BillingFrequency = billingFrequency.getRequired("billing_frequency") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun product(): Product = product.getRequired("product") + + /** + * Returns the raw JSON value of [billingFrequency]. + * + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_frequency") + @ExcludeMissing + fun _billingFrequency(): JsonField = billingFrequency + + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + + @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 [SubscriptionRate]. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionRate]. */ + class Builder internal constructor() { + + private var billingFrequency: JsonField? = null + private var product: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + product = subscriptionRate.product + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + } + + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) + + /** + * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency + } + + fun product(product: Product) = product(JsonField.of(product)) + + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun product(product: JsonField) = apply { this.product = product } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionRate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("product", product), + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SubscriptionRate = apply { + if (validated) { + return@apply + } + + billingFrequency().validate() + product().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + class BillingFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + } + + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } + + /** + * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingFrequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [BillingFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Double = quantity.getRequired("quantity") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + private var validated: Boolean = false - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BillingFrequency = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + known() + validated = true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { - fun toBuilder() = Builder().from(this) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") /** - * Returns a mutable builder for constructing an instance of [QuantitySchedule]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmStatic fun builder() = Builder() - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** A builder for [QuantitySchedule]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Product]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - private var quantity: JsonField? = null - private var startingAt: JsonField? = null - private var endingBefore: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmSynthetic - internal fun from(quantitySchedule: QuantitySchedule) = apply { - quantity = quantitySchedule.quantity - startingAt = quantitySchedule.startingAt - endingBefore = quantitySchedule.endingBefore - additionalProperties = quantitySchedule.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + private var validated: Boolean = false /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): Product = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + id() + name() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [QuantitySchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): QuantitySchedule = - QuantitySchedule( - checkRequired("quantity", quantity), - checkRequired("startingAt", startingAt), - endingBefore, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): QuantitySchedule = apply { - if (validated) { - return@apply + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - quantity() - startingAt() - endingBefore() - validated = true - } + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is QuantitySchedule && - quantity == other.quantity && - startingAt == other.startingAt && - endingBefore == other.endingBefore && + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + product == other.product && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(quantity, startingAt, endingBefore, additionalProperties) + Objects.hash(billingFrequency, product, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" } - class SubscriptionRate + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val billingFrequency: JsonField, - private val product: JsonField, + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("billing_frequency") + @JsonProperty("anchor_date") @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product") @ExcludeMissing product: JsonField = JsonMissing.of(), - ) : this(billingFrequency, product, mutableMapOf()) + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") + @ExcludeMissing + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) /** + * The date this subscription's billing cycle is anchored to. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun billingFrequency(): BillingFrequency = billingFrequency.getRequired("billing_frequency") + fun anchorDate(): OffsetDateTime = anchorDate.getRequired("anchor_date") /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun product(): Product = product.getRequired("product") + fun invoicePlacement(): InvoicePlacement = invoicePlacement.getRequired("invoice_placement") /** - * Returns the raw JSON value of [billingFrequency]. + * Returns the raw JSON value of [anchorDate]. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [anchorDate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("billing_frequency") + @JsonProperty("anchor_date") @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency + fun _anchorDate(): JsonField = anchorDate /** - * Returns the raw JSON value of [product]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + @JsonProperty("invoice_placement") + @ExcludeMissing + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2570,55 +3611,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. + * Returns a mutable builder for constructing an instance of [BillingCycleConfig]. * * The following fields are required: * ```java - * .billingFrequency() - * .product() + * .anchorDate() + * .invoicePlacement() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionRate]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var billingFrequency: JsonField? = null - private var product: JsonField? = null + private var anchorDate: JsonField? = null + private var invoicePlacement: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - product = subscriptionRate.product - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() } - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + /** The date this subscription's billing cycle is anchored to. */ + fun anchorDate(anchorDate: OffsetDateTime) = anchorDate(JsonField.of(anchorDate)) /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * Sets [Builder.anchorDate] to an arbitrary JSON value. * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.anchorDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate } - fun product(product: Product) = product(JsonField.of(product)) + /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. + */ + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.product] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.product] with a well-typed [Product] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun product(product: JsonField) = apply { this.product = product } + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2640,22 +3688,22 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionRate]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .billingFrequency() - * .product() + * .anchorDate() + * .invoicePlacement() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("product", product), + fun build(): BillingCycleConfig = + BillingCycleConfig( + checkRequired("anchorDate", anchorDate), + checkRequired("invoicePlacement", invoicePlacement), additionalProperties.toMutableMap(), ) } @@ -2671,13 +3719,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): SubscriptionRate = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - billingFrequency().validate() - product().validate() + anchorDate() + invoicePlacement().validate() validated = true } @@ -2697,10 +3745,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) - class BillingFrequency + /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. + */ + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2716,42 +3768,34 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [BillingFrequency]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [BillingFrequency] can contain an unknown value in a couple of cases: + * An instance of [InvoicePlacement] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [BillingFrequency] was instantiated with an + * An enum member indicating that [InvoicePlacement] was instantiated with an * unknown value. */ _UNKNOWN, @@ -2766,10 +3810,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -2784,11 +3826,9 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE + else -> throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") } /** @@ -2817,7 +3857,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): BillingFrequency = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -2847,7 +3887,7 @@ private constructor( return true } - return other is BillingFrequency && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -2855,231 +3895,25 @@ private constructor( override fun toString() = value.toString() } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Product]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - product == other.product && + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(billingFrequency, product, additionalProperties) + Objects.hash(anchorDate, invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -3391,6 +4225,7 @@ private constructor( startingAt == other.startingAt && subscriptionRate == other.subscriptionRate && id == other.id && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && endingBefore == other.endingBefore && @@ -3410,6 +4245,7 @@ private constructor( startingAt, subscriptionRate, id, + billingCycleConfig, customFields, description, endingBefore, @@ -3423,5 +4259,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" + "Subscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" } diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParams.kt index 9e600c6b..4577dd6f 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParams.kt @@ -94,6 +94,15 @@ private constructor( */ fun threshold(): Double = body.threshold() + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Defines the balances that are considered when evaluating the alert. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alertSpecifiers(): Optional> = body.alertSpecifiers() + /** * For threshold notifications of type `usage_threshold_reached`, specifies which billable * metric to track the usage for. @@ -218,6 +227,13 @@ private constructor( */ fun _threshold(): JsonField = body._threshold() + /** + * Returns the raw JSON value of [alertSpecifiers]. + * + * Unlike [alertSpecifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _alertSpecifiers(): JsonField> = body._alertSpecifiers() + /** * Returns the raw JSON value of [billableMetricId]. * @@ -347,8 +363,8 @@ private constructor( * - [alertType] * - [name] * - [threshold] + * - [alertSpecifiers] * - [billableMetricId] - * - [creditGrantTypeFilters] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -391,6 +407,34 @@ private constructor( */ fun threshold(threshold: JsonField) = apply { body.threshold(threshold) } + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Defines the balances that are considered when evaluating the alert. + */ + fun alertSpecifiers(alertSpecifiers: List) = apply { + body.alertSpecifiers(alertSpecifiers) + } + + /** + * Sets [Builder.alertSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.alertSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun alertSpecifiers(alertSpecifiers: JsonField>) = apply { + body.alertSpecifiers(alertSpecifiers) + } + + /** + * Adds a single [AlertSpecifier] to [alertSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlertSpecifier(alertSpecifier: AlertSpecifier) = apply { + body.addAlertSpecifier(alertSpecifier) + } + /** * For threshold notifications of type `usage_threshold_reached`, specifies which billable * metric to track the usage for. @@ -770,6 +814,7 @@ private constructor( private val alertType: JsonField, private val name: JsonField, private val threshold: JsonField, + private val alertSpecifiers: JsonField>, private val billableMetricId: JsonField, private val creditGrantTypeFilters: JsonField>, private val creditTypeId: JsonField, @@ -793,6 +838,9 @@ private constructor( @JsonProperty("threshold") @ExcludeMissing threshold: JsonField = JsonMissing.of(), + @JsonProperty("alert_specifiers") + @ExcludeMissing + alertSpecifiers: JsonField> = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -828,6 +876,7 @@ private constructor( alertType, name, threshold, + alertSpecifiers, billableMetricId, creditGrantTypeFilters, creditTypeId, @@ -867,6 +916,16 @@ private constructor( */ fun threshold(): Double = threshold.getRequired("threshold") + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Defines the balances that are considered when evaluating the alert. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alertSpecifiers(): Optional> = + alertSpecifiers.getOptional("alert_specifiers") + /** * For threshold notifications of type `usage_threshold_reached`, specifies which billable * metric to track the usage for. @@ -998,6 +1057,16 @@ private constructor( */ @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold + /** + * Returns the raw JSON value of [alertSpecifiers]. + * + * Unlike [alertSpecifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("alert_specifiers") + @ExcludeMissing + fun _alertSpecifiers(): JsonField> = alertSpecifiers + /** * Returns the raw JSON value of [billableMetricId]. * @@ -1135,6 +1204,7 @@ private constructor( private var alertType: JsonField? = null private var name: JsonField? = null private var threshold: JsonField? = null + private var alertSpecifiers: JsonField>? = null private var billableMetricId: JsonField = JsonMissing.of() private var creditGrantTypeFilters: JsonField>? = null private var creditTypeId: JsonField = JsonMissing.of() @@ -1153,6 +1223,7 @@ private constructor( alertType = body.alertType name = body.name threshold = body.threshold + alertSpecifiers = body.alertSpecifiers.map { it.toMutableList() } billableMetricId = body.billableMetricId creditGrantTypeFilters = body.creditGrantTypeFilters.map { it.toMutableList() } creditTypeId = body.creditTypeId @@ -1207,6 +1278,36 @@ private constructor( */ fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Defines the balances that are considered when evaluating the alert. + */ + fun alertSpecifiers(alertSpecifiers: List) = + alertSpecifiers(JsonField.of(alertSpecifiers)) + + /** + * Sets [Builder.alertSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.alertSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun alertSpecifiers(alertSpecifiers: JsonField>) = apply { + this.alertSpecifiers = alertSpecifiers.map { it.toMutableList() } + } + + /** + * Adds a single [AlertSpecifier] to [alertSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlertSpecifier(alertSpecifier: AlertSpecifier) = apply { + alertSpecifiers = + (alertSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("alertSpecifiers", it).add(alertSpecifier) + } + } + /** * For threshold notifications of type `usage_threshold_reached`, specifies which * billable metric to track the usage for. @@ -1486,6 +1587,7 @@ private constructor( checkRequired("alertType", alertType), checkRequired("name", name), checkRequired("threshold", threshold), + (alertSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, billableMetricId, (creditGrantTypeFilters ?: JsonMissing.of()).map { it.toImmutable() }, creditTypeId, @@ -1520,6 +1622,7 @@ private constructor( alertType().validate() name() threshold() + alertSpecifiers().ifPresent { it.forEach { it.validate() } } billableMetricId() creditGrantTypeFilters() creditTypeId() @@ -1553,6 +1656,7 @@ private constructor( (alertType.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (threshold.asKnown().isPresent) 1 else 0) + + (alertSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (creditGrantTypeFilters.asKnown().getOrNull()?.size ?: 0) + (if (creditTypeId.asKnown().isPresent) 1 else 0) + @@ -1574,6 +1678,7 @@ private constructor( alertType == other.alertType && name == other.name && threshold == other.threshold && + alertSpecifiers == other.alertSpecifiers && billableMetricId == other.billableMetricId && creditGrantTypeFilters == other.creditGrantTypeFilters && creditTypeId == other.creditTypeId && @@ -1593,6 +1698,7 @@ private constructor( alertType, name, threshold, + alertSpecifiers, billableMetricId, creditGrantTypeFilters, creditTypeId, @@ -1611,7 +1717,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{alertType=$alertType, name=$name, threshold=$threshold, billableMetricId=$billableMetricId, creditGrantTypeFilters=$creditGrantTypeFilters, creditTypeId=$creditTypeId, customFieldFilters=$customFieldFilters, customerId=$customerId, evaluateOnCreate=$evaluateOnCreate, groupValues=$groupValues, invoiceTypesFilter=$invoiceTypesFilter, planId=$planId, seatFilter=$seatFilter, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" + "Body{alertType=$alertType, name=$name, threshold=$threshold, alertSpecifiers=$alertSpecifiers, billableMetricId=$billableMetricId, creditGrantTypeFilters=$creditGrantTypeFilters, creditTypeId=$creditTypeId, customFieldFilters=$customFieldFilters, customerId=$customerId, evaluateOnCreate=$evaluateOnCreate, groupValues=$groupValues, invoiceTypesFilter=$invoiceTypesFilter, planId=$planId, seatFilter=$seatFilter, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" } /** Type of the threshold notification */ @@ -1866,6 +1972,1232 @@ private constructor( override fun toString() = value.toString() } + class AlertSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of(), + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of(), + ) : this(customFieldFilters, exclude, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFieldFilters(): Optional> = + customFieldFilters.getOptional("custom_field_filters") + + /** + * If provided, the specifier will not apply to balances that matches the inclusion criteria + * and any of the excluding values. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exclude(): Optional> = exclude.getOptional("exclude") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exclude") @ExcludeMissing fun _exclude(): JsonField> = exclude + + @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 [AlertSpecifier]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertSpecifier]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = null + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(alertSpecifier: AlertSpecifier) = apply { + customFieldFilters = alertSpecifier.customFieldFilters.map { it.toMutableList() } + exclude = alertSpecifier.exclude.map { it.toMutableList() } + additionalProperties = alertSpecifier.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + /** + * If provided, the specifier will not apply to balances that matches the inclusion + * criteria and any of the excluding values. + */ + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + + /** + * Sets [Builder.exclude] to an arbitrary JSON value. + * + * You should usually call [Builder.exclude] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertSpecifier = + AlertSpecifier( + (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, + (exclude ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AlertSpecifier = apply { + if (validated) { + return@apply + } + + customFieldFilters().ifPresent { it.forEach { it.validate() } } + exclude().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + value, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + class Exclude + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customFieldFilters(): Optional> = + customFieldFilters.getOptional("custom_field_filters") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + @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 [Exclude]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Exclude]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(exclude: Exclude) = apply { + customFieldFilters = exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced + * filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = + apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Exclude]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Exclude = + Exclude( + (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Exclude = apply { + if (validated) { + return@apply + } + + customFieldFilters().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Exclude && + customFieldFilters == other.customFieldFilters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertSpecifier && + customFieldFilters == other.customFieldFilters && + exclude == other.exclude && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, exclude, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertSpecifier{customFieldFilters=$customFieldFilters, exclude=$exclude, additionalProperties=$additionalProperties}" + } + class CustomFieldFilter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParams.kt index d9ce7069..97f0f810 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParams.kt @@ -8653,9 +8653,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing `commit_ids`, + * `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not specify any of these + * fields, the override will apply when consuming any prepaid commit, postpaid commit, or + * credit * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -8976,9 +8977,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing + * `commit_ids`, `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not + * specify any of these fields, the override will apply when consuming any prepaid + * commit, postpaid commit, or credit */ fun isCommitSpecific(isCommitSpecific: Boolean) = isCommitSpecific(JsonField.of(isCommitSpecific)) @@ -9252,6 +9254,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -9264,6 +9267,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -9286,6 +9292,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -9296,6 +9303,19 @@ private constructor( mutableMapOf(), ) + /** + * Can only be used for commit specific overrides. Must be used in conjunction with one + * of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified commit, + * credit, recurring commit or recurring credit IDs. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9362,6 +9382,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -9456,6 +9486,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -9468,6 +9499,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -9479,6 +9512,39 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + /** + * Can only be used for commit specific overrides. Must be used in conjunction with + * one of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified + * commit, credit, recurring commit or recurring credit IDs. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -9664,6 +9730,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -9692,6 +9759,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -9718,7 +9786,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -10139,6 +10208,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -10151,6 +10221,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -10165,7 +10236,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } /** Required for OVERWRITE type. */ diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParams.kt index 7d81aa3d..69bc79de 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParams.kt @@ -12403,9 +12403,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing `commit_ids`, + * `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not specify any of these + * fields, the override will apply when consuming any prepaid commit, postpaid commit, or + * credit * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -12726,9 +12727,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing + * `commit_ids`, `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not + * specify any of these fields, the override will apply when consuming any prepaid + * commit, postpaid commit, or credit */ fun isCommitSpecific(isCommitSpecific: Boolean) = isCommitSpecific(JsonField.of(isCommitSpecific)) @@ -13002,6 +13004,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -13014,6 +13017,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -13036,6 +13042,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -13046,6 +13053,19 @@ private constructor( mutableMapOf(), ) + /** + * Can only be used for commit specific overrides. Must be used in conjunction with one + * of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified commit, + * credit, recurring commit or recurring credit IDs. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -13112,6 +13132,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -13206,6 +13236,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -13218,6 +13249,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -13229,6 +13262,39 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + /** + * Can only be used for commit specific overrides. Must be used in conjunction with + * one of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified + * commit, credit, recurring commit or recurring credit IDs. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -13414,6 +13480,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -13442,6 +13509,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -13468,7 +13536,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -13889,6 +13958,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -13901,6 +13971,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -13915,7 +13986,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } /** Required for OVERWRITE type. */ @@ -15979,6 +16050,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, @@ -16030,6 +16102,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), @@ -16063,6 +16138,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -16189,6 +16265,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Optional rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * Whether the created commits will use the commit rate or list rate * @@ -16377,6 +16462,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [rateType]. * @@ -16479,6 +16574,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -16505,6 +16601,7 @@ private constructor( name = recurringCommit.name netsuiteSalesOrderId = recurringCommit.netsuiteSalesOrderId proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding rateType = recurringCommit.rateType recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction @@ -16739,6 +16836,21 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Optional rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** Whether the created commits will use the commit rate or list rate */ fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -16905,6 +17017,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -16945,6 +17058,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() @@ -16984,6 +17098,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + @@ -18014,97 +18129,138 @@ private constructor( override fun toString() = value.toString() } - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Optional rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun access(): Optional = access.getOptional("access") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - @JvmField val LIST_RATE = of("LIST_RATE") + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_RATE, - LIST_RATE, /** - * An enum member indicating that [RateType] was instantiated with an unknown value. + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -18117,12 +18273,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -18140,471 +18297,456 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RateType && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val QUARTERLY = of("QUARTERLY") + fun toBuilder() = Builder().from(this) - @JvmField val ANNUAL = of("ANNUAL") + companion object { - @JvmField val WEEKLY = of("WEEKLY") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) - } + /** A builder for [Access]. */ + class Builder internal constructor() { - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - private var validated: Boolean = false + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RecurrenceFrequency = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - known() - validated = true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - return other is RecurrenceFrequency && value == other.value - } + private var validated: Boolean = false - override fun hashCode() = value.hashCode() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - override fun toString() = value.toString() - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val applySeatIncreaseConfig: JsonField, - private val subscriptionId: JsonField, - private val allocation: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_id") - @ExcludeMissing - subscriptionId: JsonField = JsonMissing.of(), - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * ID of the subscription to configure on the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun allocation(): Optional = allocation.getOptional("allocation") + companion object { - /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns the raw JSON value of [subscriptionId]. - * - * Unlike [subscriptionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_id") - @ExcludeMissing - fun _subscriptionId(): JsonField = subscriptionId + @JvmField val FLOOR = of("FLOOR") - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + @JvmField val CEILING = of("CEILING") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - fun toBuilder() = Builder().from(this) + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionId: JsonField? = null - private var allocation: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionId = subscriptionConfig.subscriptionId - allocation = subscriptionConfig.allocation - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - - /** ID of the subscription to configure on the recurring commit/credit. */ - fun subscriptionId(subscriptionId: String) = - subscriptionId(JsonField.of(subscriptionId)) + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Sets [Builder.subscriptionId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun subscriptionId(subscriptionId: JsonField) = apply { - this.subscriptionId = subscriptionId - } + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") /** - * If set to POOLED, allocation added per seat is pooled across the account. If set - * to INDIVIDUAL, each seat in the subscription will have its own allocation. + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Returns the raw JSON value of [roundingMethod]. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionId", subscriptionId), - allocation, - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply - } - - applySeatIncreaseConfig().validate() - subscriptionId() - allocation().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionId.asKnown().isPresent) 1 else 0) + - (allocation.asKnown().getOrNull()?.validity() ?: 0) - - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) - - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -18621,42 +18763,63 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. + * Returns a mutable builder for constructing an instance of [Invoice]. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ApplySeatIncreaseConfig]. */ + /** A builder for [Invoice]. */ class Builder internal constructor() { - private var isProrated: JsonField? = null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = apply { @@ -18682,20 +18845,22 @@ private constructor( } /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -18712,12 +18877,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ApplySeatIncreaseConfig = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - isProrated() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -18736,170 +18902,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } - - override fun hashCode(): Int = hashCode + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - */ - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + companion object { - companion object { + @JvmField val HALF_UP = of("HALF_UP") - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + @JvmField val FLOOR = of("FLOOR") - @JvmField val POOLED = of("POOLED") + @JvmField val CEILING = of("CEILING") - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - INDIVIDUAL, - POOLED, - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Allocation] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - POOLED, /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED - else -> Value._UNKNOWN + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - private var validated: Boolean = false + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true } - known() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Allocation && value == other.value + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -18907,118 +19087,1036 @@ private constructor( return true } - return other is SubscriptionConfig && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionId == other.subscriptionId && - allocation == other.allocation && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - applySeatIncreaseConfig, - subscriptionId, - allocation, - additionalProperties, - ) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is RecurringCommit && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - productId == other.productId && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - rateType == other.rateType && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - temporaryId == other.temporaryId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - accessAmount, - commitDuration, - priority, - productId, - startingAt, - applicableProductIds, - applicableProductTags, - description, - endingBefore, - hierarchyConfiguration, - invoiceAmount, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - override fun toString() = - "RecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" - } + @JvmField val LIST_RATE = of("LIST_RATE") - class RecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val startingAt: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val endingBefore: JsonField, - private val hierarchyConfiguration: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val proration: JsonField, - private val rateType: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - @JsonCreator - private constructor( - @JsonProperty("access_amount") - @ExcludeMissing + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applySeatIncreaseConfig: JsonField, + private val subscriptionId: JsonField, + private val allocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + + /** + * ID of the subscription to configure on the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allocation(): Optional = allocation.getOptional("allocation") + + /** + * Returns the raw JSON value of [applySeatIncreaseConfig]. + * + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + @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 [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { + + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionId = subscriptionConfig.subscriptionId + allocation = subscriptionConfig.allocation + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + } + + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + + /** ID of the subscription to configure on the recurring commit/credit. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set + * to INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionId", subscriptionId), + allocation, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + applySeatIncreaseConfig().validate() + subscriptionId() + allocation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) + + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + @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 + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { + + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } + + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } + + isProrated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmField val POOLED = of("POOLED") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } + + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } + + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allocation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionConfig && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionId == other.subscriptionId && + allocation == other.allocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applySeatIncreaseConfig, + subscriptionId, + allocation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurringCommit && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + productId == other.productId && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + rateType == other.rateType && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + temporaryId == other.temporaryId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessAmount, + commitDuration, + priority, + productId, + startingAt, + applicableProductIds, + applicableProductTags, + description, + endingBefore, + hierarchyConfiguration, + invoiceAmount, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + } + + class RecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val startingAt: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val endingBefore: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_amount") + @ExcludeMissing accessAmount: JsonField = JsonMissing.of(), @JsonProperty("commit_duration") @ExcludeMissing @@ -19054,6 +20152,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), @@ -19086,6 +20187,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -19204,6 +20306,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Optional rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * Whether the created commits will use the commit rate or list rate * @@ -19382,6 +20493,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [rateType]. * @@ -19483,6 +20604,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -19508,6 +20630,7 @@ private constructor( name = recurringCredit.name netsuiteSalesOrderId = recurringCredit.netsuiteSalesOrderId proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding rateType = recurringCredit.rateType recurrenceFrequency = recurringCredit.recurrenceFrequency rolloverFraction = recurringCredit.rolloverFraction @@ -19727,6 +20850,21 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Optional rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** Whether the created commits will use the commit rate or list rate */ fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -19788,392 +20926,910 @@ private constructor( specifiers(JsonField.of(specifiers)) /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [SubscriptionConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionConfig(subscriptionConfig: JsonField) = apply { + this.subscriptionConfig = subscriptionConfig + } + + /** + * A temporary ID that can be used to reference the recurring commit for commit specific + * overrides. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessAmount() + * .commitDuration() + * .priority() + * .productId() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringCredit = + RecurringCredit( + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("productId", productId), + checkRequired("startingAt", startingAt), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + temporaryId, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RecurringCredit = apply { + if (validated) { + return@apply + } + + accessAmount().validate() + commitDuration().validate() + priority() + productId() + startingAt() + applicableProductIds() + applicableProductTags() + description() + endingBefore() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + temporaryId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + fun unitPrice(): Double = unitPrice.getRequired("unit_price") /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * This field is required unless a subscription is attached via `subscription_config`. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } - - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + fun quantity(): Optional = quantity.getOptional("quantity") /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [creditTypeId]. * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [SubscriptionConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun subscriptionConfig(subscriptionConfig: JsonField) = apply { - this.subscriptionConfig = subscriptionConfig - } + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId /** - * A temporary ID that can be used to reference the recurring commit for commit specific - * overrides. + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. + * Returns the raw JSON value of [quantity]. * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** + * This field is required unless a subscription is attached via + * `subscription_config`. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + additionalProperties.toMutableMap(), + ) } + private var validated: Boolean = false + /** - * Returns an immutable instance of [RecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .accessAmount() - * .commitDuration() - * .priority() - * .productId() - * .startingAt() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if any required field is unset. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun build(): RecurringCredit = - RecurringCredit( - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("productId", productId), - checkRequired("startingAt", startingAt), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - temporaryId, - additionalProperties.toMutableMap(), - ) - } + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + creditTypeId() + unitPrice() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): RecurringCredit = apply { - if (validated) { - return@apply + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - accessAmount().validate() - commitDuration().validate() - priority() - productId() - startingAt() - applicableProductIds() - applicableProductTags() - description() - endingBefore() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - proration().ifPresent { it.validate() } - rateType().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - temporaryId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a period + * is determined by the recurrence_frequency. */ - @JvmSynthetic - internal fun validity(): Int = - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) - - /** The amount of commit to grant. */ - class AccessAmount + class CommitDuration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, + private val value: JsonField, + private val unit: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") + fun value(): Double = value.getRequired("value") /** - * This field is required unless a subscription is attached via `subscription_config`. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun unit(): Optional = unit.getOptional("unit") /** - * Returns the raw JSON value of [creditTypeId]. + * Returns the raw JSON value of [value]. * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [unit]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [quantity]. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + value() + unit().ifPresent { it.validate() } + validated = true } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun toBuilder() = Builder().from(this) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) - companion object { + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a mutable builder for constructing an instance of [AccessAmount]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + companion object { - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val PERIODS = of("PERIODS") - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS + } /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown value. + */ + _UNKNOWN, } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } /** - * This field is required unless a subscription is attached via - * `subscription_config`. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false /** @@ -20186,14 +21842,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): AccessAmount = apply { + fun validate(): Proration = apply { if (validated) { return@apply } - creditTypeId() - unitPrice() - quantity() + known() validated = true } @@ -20211,79 +21865,46 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + return other is Proration && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a period - * is determined by the recurrence_frequency. - */ - class CommitDuration + /** Optional rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val value: JsonField, - private val unit: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): Double = value.getRequired("value") + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun unit(): Optional = unit.getOptional("unit") - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [unit]. + * Returns the raw JSON value of [access]. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -20300,51 +21921,33 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CommitDuration]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() + private var access: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - fun value(value: Double) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun access(access: Access) = access(JsonField.of(access)) /** - * Sets [Builder.unit] to an arbitrary JSON value. + * Sets [Builder.access] to an arbitrary JSON value. * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun unit(unit: JsonField) = apply { this.unit = unit } + fun access(access: JsonField) = apply { this.access = access } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -20369,23 +21972,12 @@ private constructor( } /** - * Returns an immutable instance of [CommitDuration]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, - additionalProperties.toMutableMap(), - ) + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -20400,13 +21992,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): CommitDuration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - value() - unit().ifPresent { it.validate() } + access().ifPresent { it.validate() } validated = true } @@ -20425,94 +22016,181 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - @JvmField val PERIODS = of("PERIODS") + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, /** - * An enum member indicating that [Unit] was instantiated with an unknown value. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - _UNKNOWN, - } + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -20525,12 +22203,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Unit = apply { + fun validate(): Access = apply { if (validated) { return@apply } - known() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -20548,195 +22227,203 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - return other is Unit && value == other.value - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun hashCode() = value.hashCode() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun toString() = value.toString() - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val HALF_UP = of("HALF_UP") - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties - } + @JvmField val FLOOR = of("FLOOR") - private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + @JvmField val CEILING = of("CEILING") - override fun hashCode(): Int = hashCode + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - @JvmField val NONE = of("NONE") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmField val FIRST = of("FIRST") + private var validated: Boolean = false - @JvmField val LAST = of("LAST") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + known() + validated = true + } - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + return other is RoundingMethod && value == other.value + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + override fun hashCode() = value.hashCode() - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + override fun toString() = value.toString() } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Proration = apply { - if (validated) { - return@apply + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** Whether the created commits will use the commit rate or list rate */ @@ -20910,6 +22597,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -20919,6 +22608,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -20937,6 +22627,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -20957,6 +22648,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -20975,6 +22667,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") } @@ -21673,6 +23366,7 @@ private constructor( name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && rateType == other.rateType && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && @@ -21697,6 +23391,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -21710,7 +23405,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + "RecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" } class ResellerRoyalty @@ -25129,327 +26824,631 @@ private constructor( return@apply } - timestamp() - amount() - quantity() - unitPrice() - validated = true + timestamp() + amount() + quantity() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Schedule && + creditTypeId == other.creditTypeId && + doNotInvoice == other.doNotInvoice && + recurringSchedule == other.recurringSchedule && + scheduleItems == other.scheduleItems && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @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 [CustomFields]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [CustomFields]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is ScheduleItem && - timestamp == other.timestamp && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CustomFields = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) - } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Schedule && - creditTypeId == other.creditTypeId && - doNotInvoice == other.doNotInvoice && - recurringSchedule == other.recurringSchedule && - scheduleItems == other.scheduleItems && - additionalProperties == other.additionalProperties + return other is CustomFields && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - additionalProperties, - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduledCharge && + productId == other.productId && + schedule == other.schedule && + customFields == other.customFields && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + productId, + schedule, + customFields, + name, + netsuiteSalesOrderId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" + } + + /** + * Determines which scheduled and commit charges to consolidate onto the Contract's usage + * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for + * consolidation to occur. This field cannot be modified after a Contract has been created. If + * this field is omitted, charges will appear on a separate invoice from usage charges. + */ + class ScheduledChargesOnUsageInvoices + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("ALL") + + @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) + } + + /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ + enum class Known { + ALL + } + + /** + * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + /** + * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + else -> + throw MetronomeInvalidDataException( + "Unknown ScheduledChargesOnUsageInvoices: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScheduledChargesOnUsageInvoices = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = - "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduledChargesOnUsageInvoices && value == other.value } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SpendTracker + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val alias: JsonField, + private val applicableSpendSpecifiers: JsonField>, + private val creditTypeId: JsonField, + private val resetFrequency: JsonField, + private val additionalProperties: MutableMap, + ) { + @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("applicable_spend_specifiers") @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + applicableSpendSpecifiers: JsonField> = JsonMissing.of(), + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("reset_frequency") + @ExcludeMissing + resetFrequency: JsonField = JsonMissing.of(), + ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) - companion object { + /** + * Human-readable identifier, unique per contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun alias(): String = alias.getRequired("alias") - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun applicableSpendSpecifiers(): List = + applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [applicableSpendSpecifiers]. + * + * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + fun _applicableSpendSpecifiers(): JsonField> = + applicableSpendSpecifiers - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [resetFrequency]. + * + * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reset_frequency") + @ExcludeMissing + fun _resetFrequency(): JsonField = resetFrequency - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns a mutable builder for constructing an instance of [SpendTracker]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + @JvmStatic fun builder() = Builder() + } - validated = true - } + /** A builder for [SpendTracker]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private var alias: JsonField? = null + private var applicableSpendSpecifiers: + JsonField>? = + null + private var creditTypeId: JsonField? = null + private var resetFrequency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomFields && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + internal fun from(spendTracker: SpendTracker) = apply { + alias = spendTracker.alias + applicableSpendSpecifiers = + spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } + creditTypeId = spendTracker.creditTypeId + resetFrequency = spendTracker.resetFrequency + additionalProperties = spendTracker.additionalProperties.toMutableMap() } - return other is ScheduledCharge && - productId == other.productId && - schedule == other.schedule && - customFields == other.customFields && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - productId, - schedule, - customFields, - name, - netsuiteSalesOrderId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" - } + /** Human-readable identifier, unique per contract. */ + fun alias(alias: String) = alias(JsonField.of(alias)) - /** - * Determines which scheduled and commit charges to consolidate onto the Contract's usage - * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for - * consolidation to occur. This field cannot be modified after a Contract has been created. If - * this field is omitted, charges will appear on a separate invoice from usage charges. - */ - class ScheduledChargesOnUsageInvoices - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: List + ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) - companion object { + /** + * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: JsonField> + ) = apply { + this.applicableSpendSpecifiers = + applicableSpendSpecifiers.map { it.toMutableList() } + } - @JvmField val ALL = of("ALL") + /** + * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = + apply { + applicableSpendSpecifiers = + (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableSpendSpecifiers", it) + .add(applicableSpendSpecifier) + } + } - @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) - } + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ - enum class Known { - ALL - } + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun resetFrequency(resetFrequency: ResetFrequency) = + resetFrequency(JsonField.of(resetFrequency)) - /** - * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ALL, /** - * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated - * with an unknown value. + * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun resetFrequency(resetFrequency: JsonField) = apply { + this.resetFrequency = resetFrequency + } - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - else -> - throw MetronomeInvalidDataException( - "Unknown ScheduledChargesOnUsageInvoices: $value" - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpendTracker]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendTracker = + SpendTracker( + checkRequired("alias", alias), + checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { + it.toImmutable() + }, + checkRequired("creditTypeId", creditTypeId), + checkRequired("resetFrequency", resetFrequency), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -25461,12 +27460,15 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): ScheduledChargesOnUsageInvoices = apply { + fun validate(): SpendTracker = apply { if (validated) { return@apply } - known() + alias() + applicableSpendSpecifiers().forEach { it.validate() } + creditTypeId() + resetFrequency().validate() validated = true } @@ -25484,534 +27486,803 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (alias.asKnown().isPresent) 1 else 0) + + (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class ApplicableSpendSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sources: JsonField>, + private val spendType: JsonField, + private val discounted: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is ScheduledChargesOnUsageInvoices && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("sources") + @ExcludeMissing + sources: JsonField> = JsonMissing.of(), + @JsonProperty("spend_type") + @ExcludeMissing + spendType: JsonField = JsonMissing.of(), + @JsonProperty("discounted") + @ExcludeMissing + discounted: JsonField = JsonMissing.of(), + ) : this(sources, spendType, discounted, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun sources(): List = sources.getRequired("sources") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun spendType(): SpendType = spendType.getRequired("spend_type") - class SpendTracker - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val alias: JsonField, - private val applicableSpendSpecifiers: JsonField>, - private val creditTypeId: JsonField, - private val resetFrequency: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Filter by whether the spend was discounted. Defaults to ANY if omitted. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun discounted(): Optional = discounted.getOptional("discounted") + + /** + * Returns the raw JSON value of [sources]. + * + * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sources") + @ExcludeMissing + fun _sources(): JsonField> = sources - @JsonCreator - private constructor( - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("applicable_spend_specifiers") + /** + * Returns the raw JSON value of [spendType]. + * + * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spend_type") @ExcludeMissing - applicableSpendSpecifiers: JsonField> = JsonMissing.of(), - @JsonProperty("credit_type_id") + fun _spendType(): JsonField = spendType + + /** + * Returns the raw JSON value of [discounted]. + * + * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discounted") @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("reset_frequency") + fun _discounted(): JsonField = discounted + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - resetFrequency: JsonField = JsonMissing.of(), - ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Human-readable identifier, unique per contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun alias(): String = alias.getRequired("alias") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun applicableSpendSpecifiers(): List = - applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + /** + * Returns a mutable builder for constructing an instance of + * [ApplicableSpendSpecifier]. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + /** A builder for [ApplicableSpendSpecifier]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + private var sources: JsonField>? = null + private var spendType: JsonField? = null + private var discounted: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [applicableSpendSpecifiers]. - * - * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - fun _applicableSpendSpecifiers(): JsonField> = - applicableSpendSpecifiers + @JvmSynthetic + internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { + sources = applicableSpendSpecifier.sources.map { it.toMutableList() } + spendType = applicableSpendSpecifier.spendType + discounted = applicableSpendSpecifier.discounted + additionalProperties = + applicableSpendSpecifier.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun sources(sources: List) = sources(JsonField.of(sources)) - /** - * Returns the raw JSON value of [resetFrequency]. - * - * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reset_frequency") - @ExcludeMissing - fun _resetFrequency(): JsonField = resetFrequency + /** + * Sets [Builder.sources] to an arbitrary JSON value. + * + * You should usually call [Builder.sources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sources(sources: JsonField>) = apply { + this.sources = sources.map { it.toMutableList() } + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Adds a single [Source] to [sources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: Source) = apply { + sources = + (sources ?: JsonField.of(mutableListOf())).also { + checkKnown("sources", it).add(source) + } + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.spendType] to an arbitrary JSON value. + * + * You should usually call [Builder.spendType] with a well-typed [SpendType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun spendType(spendType: JsonField) = apply { + this.spendType = spendType + } - companion object { + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) - /** - * Returns a mutable builder for constructing an instance of [SpendTracker]. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.discounted] to an arbitrary JSON value. + * + * You should usually call [Builder.discounted] with a well-typed [Discounted] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun discounted(discounted: JsonField) = apply { + this.discounted = discounted + } - /** A builder for [SpendTracker]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var alias: JsonField? = null - private var applicableSpendSpecifiers: - JsonField>? = - null - private var creditTypeId: JsonField? = null - private var resetFrequency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmSynthetic - internal fun from(spendTracker: SpendTracker) = apply { - alias = spendTracker.alias - applicableSpendSpecifiers = - spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } - creditTypeId = spendTracker.creditTypeId - resetFrequency = spendTracker.resetFrequency - additionalProperties = spendTracker.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Human-readable identifier, unique per contract. */ - fun alias(alias: String) = alias(JsonField.of(alias)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.alias] to an arbitrary JSON value. - * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun alias(alias: JsonField) = apply { this.alias = alias } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplicableSpendSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplicableSpendSpecifier = + ApplicableSpendSpecifier( + checkRequired("sources", sources).map { it.toImmutable() }, + checkRequired("spendType", spendType), + discounted, + additionalProperties.toMutableMap(), + ) + } - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: List - ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + private var validated: Boolean = false /** - * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: JsonField> - ) = apply { - this.applicableSpendSpecifiers = - applicableSpendSpecifiers.map { it.toMutableList() } - } - - /** - * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = - apply { - applicableSpendSpecifiers = - (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableSpendSpecifiers", it) - .add(applicableSpendSpecifier) - } + fun validate(): ApplicableSpendSpecifier = apply { + if (validated) { + return@apply } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + sources().forEach { it.validate() } + spendType().validate() + discounted().ifPresent { it.validate() } + validated = true } - fun resetFrequency(resetFrequency: ResetFrequency) = - resetFrequency(JsonField.of(resetFrequency)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun resetFrequency(resetFrequency: JsonField) = apply { - this.resetFrequency = resetFrequency - } + @JvmSynthetic + internal fun validity(): Int = + (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (spendType.asKnown().getOrNull()?.validity() ?: 0) + + (discounted.asKnown().getOrNull()?.validity() ?: 0) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + class Source @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val MANUAL = of("MANUAL") - /** - * Returns an immutable instance of [SpendTracker]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SpendTracker = - SpendTracker( - checkRequired("alias", alias), - checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { - it.toImmutable() - }, - checkRequired("creditTypeId", creditTypeId), - checkRequired("resetFrequency", resetFrequency), - additionalProperties.toMutableMap(), - ) - } + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [Source]'s known values. */ + enum class Known { + THRESHOLD_RECHARGE, + MANUAL, + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): SpendTracker = apply { - if (validated) { - return@apply - } + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_RECHARGE, + MANUAL, + /** + * An enum member indicating that [Source] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE + MANUAL -> Known.MANUAL + else -> throw MetronomeInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - alias() - applicableSpendSpecifiers().forEach { it.validate() } - creditTypeId() - resetFrequency().validate() - validated = true - } + return other is Source && value == other.value + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (alias.asKnown().isPresent) 1 else 0) + - (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + class SpendType @JsonCreator private constructor(private val value: JsonField) : + Enum { - class ApplicableSpendSpecifier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sources: JsonField>, - private val spendType: JsonField, - private val discounted: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonCreator - private constructor( - @JsonProperty("sources") - @ExcludeMissing - sources: JsonField> = JsonMissing.of(), - @JsonProperty("spend_type") - @ExcludeMissing - spendType: JsonField = JsonMissing.of(), - @JsonProperty("discounted") - @ExcludeMissing - discounted: JsonField = JsonMissing.of(), - ) : this(sources, spendType, discounted, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun sources(): List = sources.getRequired("sources") + @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun spendType(): SpendType = spendType.getRequired("spend_type") + @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) + } - /** - * Filter by whether the spend was discounted. Defaults to ANY if omitted. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun discounted(): Optional = discounted.getOptional("discounted") + /** An enum containing [SpendType]'s known values. */ + enum class Known { + COMMIT_PURCHASE + } - /** - * Returns the raw JSON value of [sources]. - * - * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sources") - @ExcludeMissing - fun _sources(): JsonField> = sources + /** + * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SpendType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_PURCHASE, + /** + * An enum member indicating that [SpendType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [spendType]. - * - * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("spend_type") - @ExcludeMissing - fun _spendType(): JsonField = spendType + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_PURCHASE -> Value.COMMIT_PURCHASE + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [discounted]. - * - * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discounted") - @ExcludeMissing - fun _discounted(): JsonField = discounted + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_PURCHASE -> Known.COMMIT_PURCHASE + else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SpendType = apply { + if (validated) { + return@apply + } - companion object { + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of - * [ApplicableSpendSpecifier]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - /** A builder for [ApplicableSpendSpecifier]. */ - class Builder internal constructor() { + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + class Discounted + @JsonCreator + private constructor(private val value: JsonField) : Enum { - private var sources: JsonField>? = null - private var spendType: JsonField? = null - private var discounted: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANY = of("ANY") - @JvmSynthetic - internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { - sources = applicableSpendSpecifier.sources.map { it.toMutableList() } - spendType = applicableSpendSpecifier.spendType - discounted = applicableSpendSpecifier.discounted - additionalProperties = - applicableSpendSpecifier.additionalProperties.toMutableMap() + @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + + @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + + @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) } - fun sources(sources: List) = sources(JsonField.of(sources)) + /** An enum containing [Discounted]'s known values. */ + enum class Known { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + } /** - * Sets [Builder.sources] to an arbitrary JSON value. + * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.sources] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An instance of [Discounted] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun sources(sources: JsonField>) = apply { - this.sources = sources.map { it.toMutableList() } + enum class Value { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + /** + * An enum member indicating that [Discounted] was instantiated with an unknown + * value. + */ + _UNKNOWN, } /** - * Adds a single [Source] to [sources]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun addSource(source: Source) = apply { - sources = - (sources ?: JsonField.of(mutableListOf())).also { - checkKnown("sources", it).add(source) - } - } + fun value(): Value = + when (this) { + ANY -> Value.ANY + DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY + else -> Value._UNKNOWN + } - fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANY -> Known.ANY + DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY + else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") + } /** - * Sets [Builder.spendType] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.spendType] with a well-typed [SpendType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun spendType(spendType: JsonField) = apply { - this.spendType = spendType - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + private var validated: Boolean = false /** - * Sets [Builder.discounted] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.discounted] with a well-typed [Discounted] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun discounted(discounted: JsonField) = apply { - this.discounted = discounted - } + fun validate(): Discounted = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + known() + validated = true } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Discounted && value == other.value } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + return other is ApplicableSpendSpecifier && + sources == other.sources && + spendType == other.spendType && + discounted == other.discounted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sources, spendType, discounted, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + } + + class ResetFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + + @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + } + + /** An enum containing [ResetFrequency]'s known values. */ + enum class Known { + BILLING_PERIOD + } + + /** + * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILLING_PERIOD, /** - * Returns an immutable instance of [ApplicableSpendSpecifier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [ResetFrequency] was instantiated with an unknown + * value. */ - fun build(): ApplicableSpendSpecifier = - ApplicableSpendSpecifier( - checkRequired("sources", sources).map { it.toImmutable() }, - checkRequired("spendType", spendType), - discounted, - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILLING_PERIOD -> Value.BILLING_PERIOD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BILLING_PERIOD -> Known.BILLING_PERIOD + else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -26024,14 +28295,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ApplicableSpendSpecifier = apply { + fun validate(): ResetFrequency = apply { if (validated) { return@apply } - sources().forEach { it.validate() } - spendType().validate() - discounted().ifPresent { it.validate() } + known() validated = true } @@ -26049,460 +28318,728 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (spendType.asKnown().getOrNull()?.validity() ?: 0) + - (discounted.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - class Source @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is ResetFrequency && value == other.value + } - companion object { + override fun hashCode() = value.hashCode() - @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + override fun toString() = value.toString() + } - @JvmField val MANUAL = of("MANUAL") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } + return other is SpendTracker && + alias == other.alias && + applicableSpendSpecifiers == other.applicableSpendSpecifiers && + creditTypeId == other.creditTypeId && + resetFrequency == other.resetFrequency && + additionalProperties == other.additionalProperties + } - /** An enum containing [Source]'s known values. */ - enum class Known { - THRESHOLD_RECHARGE, - MANUAL, - } + private val hashCode: Int by lazy { + Objects.hash( + alias, + applicableSpendSpecifiers, + creditTypeId, + resetFrequency, + additionalProperties, + ) + } - /** - * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_RECHARGE, - MANUAL, - /** - * An enum member indicating that [Source] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + override fun hashCode(): Int = hashCode - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE - MANUAL -> Value.MANUAL - else -> Value._UNKNOWN - } + override fun toString() = + "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE - MANUAL -> Known.MANUAL - else -> throw MetronomeInvalidDataException("Unknown Source: $value") - } + class Subscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val subscriptionRate: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val initialQuantity: JsonField, + private val name: JsonField, + private val quantityManagementMode: JsonField, + private val seatConfig: JsonField, + private val startingAt: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonCreator + private constructor( + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("initial_quantity") + @ExcludeMissing + initialQuantity: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("temporary_id") + @ExcludeMissing + temporaryId: JsonField = JsonMissing.of(), + ) : this( + collectionSchedule, + proration, + subscriptionRate, + billingCycleConfig, + customFields, + description, + endingBefore, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAt, + temporaryId, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun proration(): Proration = proration.getRequired("proration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") + + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Exclusive end time for the subscription. If not provided, subscription inherits contract + * end date. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - private var validated: Boolean = false + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Source = apply { - if (validated) { - return@apply - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - known() - validated = true - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantityManagementMode(): Optional = + quantityManagementMode.getOptional("quantity_management_mode") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Inclusive start time for the subscription. If not provided, defaults to contract start + * date + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAt(): Optional = startingAt.getOptional("starting_at") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * A temporary ID used to reference the subscription in recurring commit/credit subscription + * configs created within the same payload. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") - return other is Source && value == other.value - } + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - class SpendType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - companion object { + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [initialQuantity]. + * + * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_quantity") + @ExcludeMissing + fun _initialQuantity(): JsonField = initialQuantity - /** An enum containing [SpendType]'s known values. */ - enum class Known { - COMMIT_PURCHASE - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [SpendType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_PURCHASE, - /** - * An enum member indicating that [SpendType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = quantityManagementMode - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_PURCHASE -> Value.COMMIT_PURCHASE - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_PURCHASE -> Known.COMMIT_PURCHASE - else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [temporaryId]. + * + * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temporary_id") + @ExcludeMissing + fun _temporaryId(): JsonField = temporaryId - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SpendType = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - known() - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** A builder for [Subscription]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var subscriptionRate: JsonField? = null + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var initialQuantity: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quantityManagementMode: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var temporaryId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return other is SpendType && value == other.value - } + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + collectionSchedule = subscription.collectionSchedule + proration = subscription.proration + subscriptionRate = subscription.subscriptionRate + billingCycleConfig = subscription.billingCycleConfig + customFields = subscription.customFields + description = subscription.description + endingBefore = subscription.endingBefore + initialQuantity = subscription.initialQuantity + name = subscription.name + quantityManagementMode = subscription.quantityManagementMode + seatConfig = subscription.seatConfig + startingAt = subscription.startingAt + temporaryId = subscription.temporaryId + additionalProperties = subscription.additionalProperties.toMutableMap() + } - override fun hashCode() = value.hashCode() + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) - override fun toString() = value.toString() + /** + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - class Discounted - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun proration(proration: Proration) = proration(JsonField.of(proration)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } - companion object { + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - @JvmField val ANY = of("ANY") + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate + } - @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) - @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } - @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) - } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) - /** An enum containing [Discounted]'s known values. */ - enum class Known { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - } + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } - /** - * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Discounted] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - /** - * An enum member indicating that [Discounted] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun description(description: String) = description(JsonField.of(description)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANY -> Value.ANY - DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY - else -> Value._UNKNOWN - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANY -> Known.ANY - DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY - else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") - } + /** + * Exclusive end time for the subscription. If not provided, subscription inherits + * contract end date. + */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + */ + fun initialQuantity(initialQuantity: Double) = + initialQuantity(JsonField.of(initialQuantity)) - private var validated: Boolean = false + /** + * Sets [Builder.initialQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.initialQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun initialQuantity(initialQuantity: JsonField) = apply { + this.initialQuantity = initialQuantity + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Discounted = apply { - if (validated) { - return@apply - } + fun name(name: String) = name(JsonField.of(name)) - known() - validated = true + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per + * seat. `seat_config` must be provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) + + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode(quantityManagementMode: JsonField) = + apply { + this.quantityManagementMode = quantityManagementMode } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Inclusive start time for the subscription. If not provided, defaults to contract + * start date + */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) - return other is Discounted && value == other.value - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - override fun hashCode() = value.hashCode() + /** + * A temporary ID used to reference the subscription in recurring commit/credit + * subscription configs created within the same payload. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) - override fun toString() = value.toString() + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is ApplicableSpendSpecifier && - sources == other.sources && - spendType == other.spendType && - discounted == other.discounted && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(sources, spendType, discounted, additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun toString() = - "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Subscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("subscriptionRate", subscriptionRate), + billingCycleConfig, + customFields, + description, + endingBefore, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAt, + temporaryId, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + collectionSchedule().validate() + proration().validate() + subscriptionRate().validate() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + endingBefore() + initialQuantity() + name() + quantityManagementMode().ifPresent { it.validate() } + seatConfig().ifPresent { it.validate() } + startingAt() + temporaryId() + validated = true } - class ResetFrequency + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (initialQuantity.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) + + class CollectionSchedule @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -26518,30 +29055,36 @@ private constructor( companion object { - @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + @JvmField val ADVANCE = of("ADVANCE") - @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - /** An enum containing [ResetFrequency]'s known values. */ + /** An enum containing [CollectionSchedule]'s known values. */ enum class Known { - BILLING_PERIOD + ADVANCE, + ARREARS, } /** - * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILLING_PERIOD, + ADVANCE, + ARREARS, /** - * An enum member indicating that [ResetFrequency] was instantiated with an unknown - * value. + * An enum member indicating that [CollectionSchedule] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -26555,39 +29098,285 @@ private constructor( */ fun value(): Value = when (this) { - BILLING_PERIOD -> Value.BILLING_PERIOD + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS else -> Value._UNKNOWN } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BILLING_PERIOD -> Known.BILLING_PERIOD - else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CollectionSchedule = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CollectionSchedule && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Proration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("invoice_behavior") + @ExcludeMissing + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) + + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoiceBehavior(): Optional = + invoiceBehavior.getOptional("invoice_behavior") + + /** + * Indicates if the partial period will be prorated or charged a full amount. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isProrated(): Optional = isProrated.getOptional("is_prorated") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + + /** + * Returns the raw JSON value of [invoiceBehavior]. + * + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_behavior") + @ExcludeMissing + fun _invoiceBehavior(): JsonField = invoiceBehavior + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding + + @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 [Proration]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Proration]. */ + class Builder internal constructor() { + + private var invoiceBehavior: JsonField = JsonMissing.of() + private var isProrated: JsonField = JsonMissing.of() + private var rounding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() + } + + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will + * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: + * The quantity increase will be billed for in-arrears at the end of the period. + */ + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) + + /** + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } + + /** Indicates if the partial period will be prorated or charged a full amount. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Proration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Proration = + Proration( + invoiceBehavior, + isProrated, + rounding, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -26600,12 +29389,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ResetFrequency = apply { + fun validate(): Proration = apply { if (validated) { return@apply } - known() + invoiceBehavior().ifPresent { it.validate() } + isProrated() + rounding().ifPresent { it.validate() } validated = true } @@ -26615,896 +29406,640 @@ private constructor( true } catch (e: MetronomeInvalidDataException) { false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResetFrequency && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpendTracker && - alias == other.alias && - applicableSpendSpecifiers == other.applicableSpendSpecifiers && - creditTypeId == other.creditTypeId && - resetFrequency == other.resetFrequency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - alias, - applicableSpendSpecifiers, - creditTypeId, - resetFrequency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" - } - - class Subscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val subscriptionRate: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val initialQuantity: JsonField, - private val name: JsonField, - private val quantityManagementMode: JsonField, - private val seatConfig: JsonField, - private val startingAt: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("initial_quantity") - @ExcludeMissing - initialQuantity: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("temporary_id") - @ExcludeMissing - temporaryId: JsonField = JsonMissing.of(), - ) : this( - collectionSchedule, - proration, - subscriptionRate, - customFields, - description, - endingBefore, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAt, - temporaryId, - mutableMapOf(), - ) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun proration(): Proration = proration.getRequired("proration") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") - - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Exclusive end time for the subscription. If not provided, subscription inherits contract - * end date. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantityManagementMode(): Optional = - quantityManagementMode.getOptional("quantity_management_mode") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - /** - * Inclusive start time for the subscription. If not provided, defaults to contract start - * date - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + */ + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * A temporary ID used to reference the subscription in recurring commit/credit subscription - * configs created within the same payload. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + companion object { - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [initialQuantity]. - * - * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("initial_quantity") - @ExcludeMissing - fun _initialQuantity(): JsonField = initialQuantity + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + } - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = quantityManagementMode + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + private var validated: Boolean = false - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [temporaryId]. - * - * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("temporary_id") - @ExcludeMissing - fun _temporaryId(): JsonField = temporaryId + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is InvoiceBehavior && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - /** - * Returns a mutable builder for constructing an instance of [Subscription]. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - /** A builder for [Subscription]. */ - class Builder internal constructor() { + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var subscriptionRate: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var initialQuantity: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantityManagementMode: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var temporaryId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - collectionSchedule = subscription.collectionSchedule - proration = subscription.proration - subscriptionRate = subscription.subscriptionRate - customFields = subscription.customFields - description = subscription.description - endingBefore = subscription.endingBefore - initialQuantity = subscription.initialQuantity - name = subscription.name - quantityManagementMode = subscription.quantityManagementMode - seatConfig = subscription.seatConfig - startingAt = subscription.startingAt - temporaryId = subscription.temporaryId - additionalProperties = subscription.additionalProperties.toMutableMap() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun proration(proration: Proration) = proration(JsonField.of(proration)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + companion object { - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + /** A builder for [Rounding]. */ + class Builder internal constructor() { - fun description(description: String) = description(JsonField.of(description)) + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - /** - * Exclusive end time for the subscription. If not provided, subscription inherits - * contract end date. - */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - */ - fun initialQuantity(initialQuantity: Double) = - initialQuantity(JsonField.of(initialQuantity)) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * Sets [Builder.initialQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.initialQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun initialQuantity(initialQuantity: JsonField) = apply { - this.initialQuantity = initialQuantity - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun name(name: String) = name(JsonField.of(name)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per - * seat. `seat_config` must be provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode(quantityManagementMode: JsonField) = - apply { - this.quantityManagementMode = quantityManagementMode + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + private var validated: Boolean = false - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } - /** - * Inclusive start time for the subscription. If not provided, defaults to contract - * start date - */ - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + decimalPlaces() + roundingMethod().validate() + validated = true + } - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * A temporary ID used to reference the subscription in recurring commit/credit - * subscription configs created within the same payload. - */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. - * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val HALF_UP = of("HALF_UP") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JvmField val FLOOR = of("FLOOR") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val CEILING = of("CEILING") - /** - * Returns an immutable instance of [Subscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Subscription = - Subscription( - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("subscriptionRate", subscriptionRate), - customFields, - description, - endingBefore, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAt, - temporaryId, - additionalProperties.toMutableMap(), - ) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Subscription = apply { - if (validated) { - return@apply - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - collectionSchedule().validate() - proration().validate() - subscriptionRate().validate() - customFields().ifPresent { it.validate() } - description() - endingBefore() - initialQuantity() - name() - quantityManagementMode().ifPresent { it.validate() } - seatConfig().ifPresent { it.validate() } - startingAt() - temporaryId() - validated = true - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (initialQuantity.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - class CollectionSchedule - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var validated: Boolean = false - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - companion object { + known() + validated = true + } - @JvmField val ADVANCE = of("ADVANCE") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val ARREARS = of("ARREARS") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } + return other is RoundingMethod && value == other.value + } - /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + override fun hashCode() = value.hashCode() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN + override fun toString() = value.toString() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CollectionSchedule && value == other.value + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" } - class Proration + class SubscriptionRate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val billingFrequency: JsonField, + private val productId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product_id") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + productId: JsonField = JsonMissing.of(), + ) : this(billingFrequency, productId, mutableMapOf()) /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun invoiceBehavior(): Optional = - invoiceBehavior.getOptional("invoice_behavior") + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") /** - * Indicates if the partial period will be prorated or charged a full amount. + * Must be subscription type product * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun isProrated(): Optional = isProrated.getOptional("is_prorated") + fun productId(): String = productId.getRequired("product_id") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [billingFrequency]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _billingFrequency(): JsonField = billingFrequency /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [productId]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("is_prorated") + @JsonProperty("product_id") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _productId(): JsonField = productId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27520,57 +30055,61 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Proration]. */ + /** + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [SubscriptionRate]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField = JsonMissing.of() - private var isProrated: JsonField = JsonMissing.of() + private var billingFrequency: JsonField? = null + private var productId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() + @JvmSynthetic + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + productId = subscriptionRate.productId + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() } /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will - * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: - * The quantity increase will be billed for in-arrears at the end of the period. + * Frequency to bill subscription with. Together with product_id, must match + * existing rate on the rate card. */ - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the field + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency } - /** Indicates if the partial period will be prorated or charged a full amount. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** Must be subscription type product */ + fun productId(productId: String) = productId(JsonField.of(productId)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.productId] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * You should usually call [Builder.productId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + fun productId(productId: JsonField) = apply { this.productId = productId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -27595,12 +30134,24 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [SubscriptionRate]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration(invoiceBehavior, isProrated, additionalProperties.toMutableMap()) + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("productId", productId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -27615,13 +30166,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - invoiceBehavior().ifPresent { it.validate() } - isProrated() + billingFrequency().validate() + productId() validated = true } @@ -27641,16 +30192,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (productId.asKnown().isPresent) 1 else 0) /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. */ - class InvoiceBehavior + class BillingFrequency @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27666,24 +30215,30 @@ private constructor( companion object { - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + @JvmField val MONTHLY = of("MONTHLY") - @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + @JvmField val QUARTERLY = of("QUARTERLY") - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) } - /** An enum containing [InvoiceBehavior]'s known values. */ + /** An enum containing [BillingFrequency]'s known values. */ enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, } /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * An instance of [BillingFrequency] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -27691,10 +30246,12 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an + * An enum member indicating that [BillingFrequency] was instantiated with an * unknown value. */ _UNKNOWN, @@ -27709,8 +30266,10 @@ private constructor( */ fun value(): Value = when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -27725,10 +30284,12 @@ private constructor( */ fun known(): Known = when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY else -> - throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") } /** @@ -27757,7 +30318,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): InvoiceBehavior = apply { + fun validate(): BillingFrequency = apply { if (validated) { return@apply } @@ -27787,7 +30348,7 @@ private constructor( return true } - return other is InvoiceBehavior && value == other.value + return other is BillingFrequency && value == other.value } override fun hashCode() = value.hashCode() @@ -27800,79 +30361,78 @@ private constructor( return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + productId == other.productId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(billingFrequency, productId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" } - class SubscriptionRate + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val billingFrequency: JsonField, - private val productId: JsonField, + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("billing_frequency") + @JsonProperty("anchor_date") @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product_id") + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") @ExcludeMissing - productId: JsonField = JsonMissing.of(), - ) : this(billingFrequency, productId, mutableMapOf()) + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. + * The date to anchor the billing cycle to. If omitted, defaults to the contract's usage + * invoice billing cycle anchor date. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + fun anchorDate(): Optional = anchorDate.getOptional("anchor_date") /** - * Must be subscription type product + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun productId(): String = productId.getRequired("product_id") + fun invoicePlacement(): Optional = + invoicePlacement.getOptional("invoice_placement") /** - * Returns the raw JSON value of [billingFrequency]. + * Returns the raw JSON value of [anchorDate]. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [anchorDate], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("billing_frequency") + @JsonProperty("anchor_date") @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency + fun _anchorDate(): JsonField = anchorDate /** - * Returns the raw JSON value of [productId]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("product_id") + @JsonProperty("invoice_placement") @ExcludeMissing - fun _productId(): JsonField = productId + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27889,60 +30449,59 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` + * Returns a mutable builder for constructing an instance of [BillingCycleConfig]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionRate]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var billingFrequency: JsonField? = null - private var productId: JsonField? = null + private var anchorDate: JsonField = JsonMissing.of() + private var invoicePlacement: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - productId = subscriptionRate.productId - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() } /** - * Frequency to bill subscription with. Together with product_id, must match - * existing rate on the rate card. + * The date to anchor the billing cycle to. If omitted, defaults to the contract's + * usage invoice billing cycle anchor date. */ - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + fun anchorDate(anchorDate: OffsetDateTime) = anchorDate(JsonField.of(anchorDate)) /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * Sets [Builder.anchorDate] to an arbitrary JSON value. * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.anchorDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate } - /** Must be subscription type product */ - fun productId(productId: String) = productId(JsonField.of(productId)) + /** + * Controls whether this subscription consolidates onto usage invoices or gets its + * own scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. + */ + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.productId] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun productId(productId: JsonField) = apply { this.productId = productId } + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -27967,22 +30526,14 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionRate]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("productId", productId), + fun build(): BillingCycleConfig = + BillingCycleConfig( + anchorDate, + invoicePlacement, additionalProperties.toMutableMap(), ) } @@ -27999,13 +30550,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): SubscriptionRate = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - billingFrequency().validate() - productId() + anchorDate() + invoicePlacement().ifPresent { it.validate() } validated = true } @@ -28025,14 +30576,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (productId.asKnown().isPresent) 1 else 0) + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. */ - class BillingFrequency + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -28048,30 +30599,24 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [BillingFrequency]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [BillingFrequency] can contain an unknown value in a couple of + * An instance of [InvoicePlacement] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -28079,12 +30624,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [BillingFrequency] was instantiated with an + * An enum member indicating that [InvoicePlacement] was instantiated with an * unknown value. */ _UNKNOWN, @@ -28099,10 +30642,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -28117,12 +30658,10 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE else -> - throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") } /** @@ -28151,7 +30690,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): BillingFrequency = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -28181,7 +30720,7 @@ private constructor( return true } - return other is BillingFrequency && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -28194,20 +30733,20 @@ private constructor( return true } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - productId == other.productId && + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(billingFrequency, productId, additionalProperties) + Objects.hash(anchorDate, invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -28790,6 +31329,7 @@ private constructor( collectionSchedule == other.collectionSchedule && proration == other.proration && subscriptionRate == other.subscriptionRate && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && endingBefore == other.endingBefore && @@ -28807,6 +31347,7 @@ private constructor( collectionSchedule, proration, subscriptionRate, + billingCycleConfig, customFields, description, endingBefore, @@ -28823,7 +31364,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, customFields=$customFields, description=$description, endingBefore=$endingBefore, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAt=$startingAt, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAt=$startingAt, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" } class Transition diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponse.kt index 7c770072..3f76105a 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponse.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponse.kt @@ -4121,6 +4121,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -4180,6 +4181,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -4211,6 +4215,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -4362,6 +4367,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - * The commits will be created on the usage invoice frequency. If provided: - The @@ -4572,6 +4586,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -4665,6 +4689,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -4694,6 +4719,7 @@ private constructor( name = recurringCommit.name netsuiteSalesOrderId = recurringCommit.netsuiteSalesOrderId proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction specifiers = recurringCommit.specifiers.map { it.toMutableList() } @@ -4972,6 +4998,28 @@ private constructor( this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not * provided: - The commits will be created on the usage invoice frequency. If @@ -5118,6 +5166,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -5160,6 +5209,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -5200,6 +5250,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -6791,123 +6842,147 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an + * unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JsonProperty("access") + @ExcludeMissing + fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated - * with an unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -6920,12 +6995,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -6944,50 +7020,1027 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - return other is RecurrenceFrequency && value == other.value - } + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun hashCode() = value.hashCode() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - return other is RecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - contract == other.contract && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit. For USD, this means + * rounding to the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit. For USD, this means + * rounding to the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + contract == other.contract && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } private val hashCode: Int by lazy { Objects.hash( @@ -7008,6 +8061,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -7019,7 +8073,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } class RecurringCredit @@ -7041,6 +8095,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -7097,6 +8152,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -7127,6 +8185,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -7269,6 +8328,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - * The commits will be created on the usage invoice frequency. If provided: - The @@ -7469,6 +8537,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -7561,6 +8639,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -7589,6 +8668,7 @@ private constructor( name = recurringCredit.name netsuiteSalesOrderId = recurringCredit.netsuiteSalesOrderId proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding recurrenceFrequency = recurringCredit.recurrenceFrequency rolloverFraction = recurringCredit.rolloverFraction specifiers = recurringCredit.specifiers.map { it.toMutableList() } @@ -7852,6 +8932,28 @@ private constructor( this.proration = proration } + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not * provided: - The commits will be created on the usage invoice frequency. If @@ -7997,6 +9099,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -8038,6 +9141,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -8077,6 +9181,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -9278,76 +10383,235 @@ private constructor( FIRST_AND_LAST, } - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access") + @ExcludeMissing + fun _access(): JsonField = access + + @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 + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + /** - * An enum member indicating that [Proration] was instantiated with an - * unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -9360,12 +10624,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Proration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } validated = true } @@ -9384,19 +10648,420 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit. For USD, this means + * rounding to the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** @@ -9431,6 +11096,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -9440,6 +11107,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -9458,6 +11126,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated * with an unknown value. @@ -9478,6 +11147,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -9496,6 +11166,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException( "Unknown RecurrenceFrequency: $value" @@ -9589,6 +11260,7 @@ private constructor( name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -9614,6 +11286,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -9625,7 +11298,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } /** diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParams.kt new file mode 100644 index 00000000..d0b182f2 --- /dev/null +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParams.kt @@ -0,0 +1,1045 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.metronome.api.models.v1.contracts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.metronome.api.core.ExcludeMissing +import com.metronome.api.core.JsonField +import com.metronome.api.core.JsonMissing +import com.metronome.api.core.JsonValue +import com.metronome.api.core.Params +import com.metronome.api.core.checkRequired +import com.metronome.api.core.http.Headers +import com.metronome.api.core.http.QueryParams +import com.metronome.api.errors.MetronomeInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Get the history of subscription seats schedule over time for a given `subscription_id`. This + * endpoint provides information about seat assignments and total quantities for different time + * periods, allowing you to track how seat assignments have changed over time. + * + * ### Use this endpoint to: + * - Track changes to seat assignments over time + * - Get seat schedule for a specific date using the `covering_date` parameter + * - Get seat schedule history with optional date range filtering using `starting_at` and + * `ending_before` + * + * ### Key response fields: + * - data: array of seat schedule entries with time periods, quantity, and assignments + * - next_page: cursor for pagination to retrieve additional results + * + * ### Usage guidelines: + * - Use `covering_date` to get the active seats for a specific point in time. `covering_date` + * cannot be used with `starting_at` or `ending_before`. + * - Use `starting_at` and `ending_before` to filter results by time range. `starting_at` and + * `ending_before` cannot be used with `covering_date`. + * - Maximum limit is 10 seat schedule entries per request + * - Results are ordered by `starting_at` timestamp + */ +class ContractGetSubscriptionSeatsHistoryParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun contractId(): String = body.contractId() + + /** + * @throws MetronomeInvalidDataException if 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() + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = body.subscriptionId() + + /** + * Get the seats history segment for the covering date. Cannot be used with `starting_at` or + * `ending_before`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coveringDate(): Optional = body.coveringDate() + + /** + * Cursor for pagination. Use the value from the `next_page` field of the previous response to + * retrieve the next page of results. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = body.cursor() + + /** + * Include seats history segments that are active at or before this timestamp. Use with + * `starting_at` to get a specific time range. If not set, there's no upper bound. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endingBefore(): Optional = body.endingBefore() + + /** + * Maximum number of seat schedule entries to return. Defaults to 10. Required range: 1 <= x + * <= 10. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = body.limit() + + /** + * Include seats history segments that are active at or after this timestamp. Use with + * `ending_before` to get a specific time range. If not set, there's no lower bound. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startingAt(): Optional = body.startingAt() + + /** + * Returns the raw JSON value of [contractId]. + * + * Unlike [contractId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _contractId(): JsonField = body._contractId() + + /** + * 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 [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _subscriptionId(): JsonField = body._subscriptionId() + + /** + * Returns the raw JSON value of [coveringDate]. + * + * Unlike [coveringDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _coveringDate(): JsonField = body._coveringDate() + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _cursor(): JsonField = body._cursor() + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endingBefore(): JsonField = body._endingBefore() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField = body._limit() + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startingAt(): JsonField = body._startingAt() + + 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 + * [ContractGetSubscriptionSeatsHistoryParams]. + * + * The following fields are required: + * ```java + * .contractId() + * .customerId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContractGetSubscriptionSeatsHistoryParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + contractGetSubscriptionSeatsHistoryParams: ContractGetSubscriptionSeatsHistoryParams + ) = apply { + body = contractGetSubscriptionSeatsHistoryParams.body.toBuilder() + additionalHeaders = + contractGetSubscriptionSeatsHistoryParams.additionalHeaders.toBuilder() + additionalQueryParams = + contractGetSubscriptionSeatsHistoryParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [contractId] + * - [customerId] + * - [subscriptionId] + * - [coveringDate] + * - [cursor] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun contractId(contractId: String) = apply { body.contractId(contractId) } + + /** + * Sets [Builder.contractId] to an arbitrary JSON value. + * + * You should usually call [Builder.contractId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun contractId(contractId: JsonField) = apply { body.contractId(contractId) } + + 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) } + + fun subscriptionId(subscriptionId: String) = apply { body.subscriptionId(subscriptionId) } + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + body.subscriptionId(subscriptionId) + } + + /** + * Get the seats history segment for the covering date. Cannot be used with `starting_at` or + * `ending_before`. + */ + fun coveringDate(coveringDate: OffsetDateTime?) = apply { body.coveringDate(coveringDate) } + + /** Alias for calling [Builder.coveringDate] with `coveringDate.orElse(null)`. */ + fun coveringDate(coveringDate: Optional) = + coveringDate(coveringDate.getOrNull()) + + /** + * Sets [Builder.coveringDate] to an arbitrary JSON value. + * + * You should usually call [Builder.coveringDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coveringDate(coveringDate: JsonField) = apply { + body.coveringDate(coveringDate) + } + + /** + * Cursor for pagination. Use the value from the `next_page` field of the previous response + * to retrieve the next page of results. + */ + fun cursor(cursor: String?) = apply { body.cursor(cursor) } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + + /** + * Include seats history segments that are active at or before this timestamp. Use with + * `starting_at` to get a specific time range. If not set, there's no upper bound. + */ + fun endingBefore(endingBefore: OffsetDateTime?) = apply { body.endingBefore(endingBefore) } + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + body.endingBefore(endingBefore) + } + + /** + * Maximum number of seat schedule entries to return. Defaults to 10. Required range: 1 <= x + * <= 10. + */ + fun limit(limit: Long?) = apply { body.limit(limit) } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } + + /** + * Include seats history segments that are active at or after this timestamp. Use with + * `ending_before` to get a specific time range. If not set, there's no lower bound. + */ + fun startingAt(startingAt: OffsetDateTime?) = apply { body.startingAt(startingAt) } + + /** Alias for calling [Builder.startingAt] with `startingAt.orElse(null)`. */ + fun startingAt(startingAt: Optional) = startingAt(startingAt.getOrNull()) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + body.startingAt(startingAt) + } + + 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 [ContractGetSubscriptionSeatsHistoryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .contractId() + * .customerId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ContractGetSubscriptionSeatsHistoryParams = + ContractGetSubscriptionSeatsHistoryParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val contractId: JsonField, + private val customerId: JsonField, + private val subscriptionId: JsonField, + private val coveringDate: JsonField, + private val cursor: JsonField, + private val endingBefore: JsonField, + private val limit: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("contract_id") + @ExcludeMissing + contractId: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + customerId: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("covering_date") + @ExcludeMissing + coveringDate: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this( + contractId, + customerId, + subscriptionId, + coveringDate, + cursor, + endingBefore, + limit, + startingAt, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun contractId(): String = contractId.getRequired("contract_id") + + /** + * @throws MetronomeInvalidDataException if 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("customer_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Get the seats history segment for the covering date. Cannot be used with `starting_at` or + * `ending_before`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun coveringDate(): Optional = coveringDate.getOptional("covering_date") + + /** + * Cursor for pagination. Use the value from the `next_page` field of the previous response + * to retrieve the next page of results. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * Include seats history segments that are active at or before this timestamp. Use with + * `starting_at` to get a specific time range. If not set, there's no upper bound. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * Maximum number of seat schedule entries to return. Defaults to 10. Required range: 1 <= x + * <= 10. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * Include seats history segments that are active at or after this timestamp. Use with + * `ending_before` to get a specific time range. If not set, there's no lower bound. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAt(): Optional = startingAt.getOptional("starting_at") + + /** + * Returns the raw JSON value of [contractId]. + * + * Unlike [contractId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("contract_id") + @ExcludeMissing + fun _contractId(): JsonField = contractId + + /** + * Returns the raw JSON value of [customerId]. + * + * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_id") + @ExcludeMissing + fun _customerId(): JsonField = customerId + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [coveringDate]. + * + * Unlike [coveringDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("covering_date") + @ExcludeMissing + fun _coveringDate(): JsonField = coveringDate + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + @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 + * .contractId() + * .customerId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var contractId: JsonField? = null + private var customerId: JsonField? = null + private var subscriptionId: JsonField? = null + private var coveringDate: JsonField = JsonMissing.of() + private var cursor: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + contractId = body.contractId + customerId = body.customerId + subscriptionId = body.subscriptionId + coveringDate = body.coveringDate + cursor = body.cursor + endingBefore = body.endingBefore + limit = body.limit + startingAt = body.startingAt + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun contractId(contractId: String) = contractId(JsonField.of(contractId)) + + /** + * Sets [Builder.contractId] to an arbitrary JSON value. + * + * You should usually call [Builder.contractId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun contractId(contractId: JsonField) = apply { this.contractId = contractId } + + 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 } + + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Get the seats history segment for the covering date. Cannot be used with + * `starting_at` or `ending_before`. + */ + fun coveringDate(coveringDate: OffsetDateTime?) = + coveringDate(JsonField.ofNullable(coveringDate)) + + /** Alias for calling [Builder.coveringDate] with `coveringDate.orElse(null)`. */ + fun coveringDate(coveringDate: Optional) = + coveringDate(coveringDate.getOrNull()) + + /** + * Sets [Builder.coveringDate] to an arbitrary JSON value. + * + * You should usually call [Builder.coveringDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun coveringDate(coveringDate: JsonField) = apply { + this.coveringDate = coveringDate + } + + /** + * Cursor for pagination. Use the value from the `next_page` field of the previous + * response to retrieve the next page of results. + */ + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + /** + * Include seats history segments that are active at or before this timestamp. Use with + * `starting_at` to get a specific time range. If not set, there's no upper bound. + */ + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + /** + * Maximum number of seat schedule entries to return. Defaults to 10. Required range: 1 + * <= x <= 10. + */ + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** + * Include seats history segments that are active at or after this timestamp. Use with + * `ending_before` to get a specific time range. If not set, there's no lower bound. + */ + fun startingAt(startingAt: OffsetDateTime?) = + startingAt(JsonField.ofNullable(startingAt)) + + /** Alias for calling [Builder.startingAt] with `startingAt.orElse(null)`. */ + fun startingAt(startingAt: Optional) = + startingAt(startingAt.getOrNull()) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .contractId() + * .customerId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("contractId", contractId), + checkRequired("customerId", customerId), + checkRequired("subscriptionId", subscriptionId), + coveringDate, + cursor, + endingBefore, + limit, + startingAt, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + contractId() + customerId() + subscriptionId() + coveringDate() + cursor() + endingBefore() + limit() + startingAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (contractId.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (coveringDate.asKnown().isPresent) 1 else 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + contractId == other.contractId && + customerId == other.customerId && + subscriptionId == other.subscriptionId && + coveringDate == other.coveringDate && + cursor == other.cursor && + endingBefore == other.endingBefore && + limit == other.limit && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + contractId, + customerId, + subscriptionId, + coveringDate, + cursor, + endingBefore, + limit, + startingAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{contractId=$contractId, customerId=$customerId, subscriptionId=$subscriptionId, coveringDate=$coveringDate, cursor=$cursor, endingBefore=$endingBefore, limit=$limit, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContractGetSubscriptionSeatsHistoryParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ContractGetSubscriptionSeatsHistoryParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponse.kt new file mode 100644 index 00000000..7166b044 --- /dev/null +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponse.kt @@ -0,0 +1,576 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.metronome.api.models.v1.contracts + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.metronome.api.core.ExcludeMissing +import com.metronome.api.core.JsonField +import com.metronome.api.core.JsonMissing +import com.metronome.api.core.JsonValue +import com.metronome.api.core.checkKnown +import com.metronome.api.core.checkRequired +import com.metronome.api.core.toImmutable +import com.metronome.api.errors.MetronomeInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ContractGetSubscriptionSeatsHistoryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val nextPage: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("next_page") @ExcludeMissing nextPage: JsonField = JsonMissing.of(), + ) : this(data, nextPage, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * Cursor for the next page of results + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPage(): Optional = nextPage.getOptional("next_page") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextPage]. + * + * Unlike [nextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_page") @ExcludeMissing fun _nextPage(): JsonField = nextPage + + @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 + * [ContractGetSubscriptionSeatsHistoryResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextPage() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContractGetSubscriptionSeatsHistoryResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextPage: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + contractGetSubscriptionSeatsHistoryResponse: ContractGetSubscriptionSeatsHistoryResponse + ) = apply { + data = contractGetSubscriptionSeatsHistoryResponse.data.map { it.toMutableList() } + nextPage = contractGetSubscriptionSeatsHistoryResponse.nextPage + additionalProperties = + contractGetSubscriptionSeatsHistoryResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Cursor for the next page of results */ + fun nextPage(nextPage: String?) = nextPage(JsonField.ofNullable(nextPage)) + + /** Alias for calling [Builder.nextPage] with `nextPage.orElse(null)`. */ + fun nextPage(nextPage: Optional) = nextPage(nextPage.getOrNull()) + + /** + * Sets [Builder.nextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPage] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextPage(nextPage: JsonField) = apply { this.nextPage = nextPage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContractGetSubscriptionSeatsHistoryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextPage() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ContractGetSubscriptionSeatsHistoryResponse = + ContractGetSubscriptionSeatsHistoryResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextPage", nextPage), + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ContractGetSubscriptionSeatsHistoryResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextPage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextPage.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val assignedSeatIds: JsonField>, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val totalQuantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("assigned_seat_ids") + @ExcludeMissing + assignedSeatIds: JsonField> = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("total_quantity") + @ExcludeMissing + totalQuantity: JsonField = JsonMissing.of(), + ) : this(assignedSeatIds, endingBefore, startingAt, totalQuantity, mutableMapOf()) + + /** + * Array of seat IDs that are assigned in this period + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun assignedSeatIds(): List = assignedSeatIds.getRequired("assigned_seat_ids") + + /** + * The end time of this seat schedule period (null if ongoing) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * The start time of this seat schedule period + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * Total number of assigned and unassigned seats in this period + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun totalQuantity(): Long = totalQuantity.getRequired("total_quantity") + + /** + * Returns the raw JSON value of [assignedSeatIds]. + * + * Unlike [assignedSeatIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("assigned_seat_ids") + @ExcludeMissing + fun _assignedSeatIds(): JsonField> = assignedSeatIds + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [totalQuantity]. + * + * Unlike [totalQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_quantity") + @ExcludeMissing + fun _totalQuantity(): JsonField = totalQuantity + + @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 + * .assignedSeatIds() + * .endingBefore() + * .startingAt() + * .totalQuantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var assignedSeatIds: JsonField>? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var totalQuantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + assignedSeatIds = data.assignedSeatIds.map { it.toMutableList() } + endingBefore = data.endingBefore + startingAt = data.startingAt + totalQuantity = data.totalQuantity + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Array of seat IDs that are assigned in this period */ + fun assignedSeatIds(assignedSeatIds: List) = + assignedSeatIds(JsonField.of(assignedSeatIds)) + + /** + * Sets [Builder.assignedSeatIds] to an arbitrary JSON value. + * + * You should usually call [Builder.assignedSeatIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun assignedSeatIds(assignedSeatIds: JsonField>) = apply { + this.assignedSeatIds = assignedSeatIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [assignedSeatIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAssignedSeatId(assignedSeatId: String) = apply { + assignedSeatIds = + (assignedSeatIds ?: JsonField.of(mutableListOf())).also { + checkKnown("assignedSeatIds", it).add(assignedSeatId) + } + } + + /** The end time of this seat schedule period (null if ongoing) */ + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + /** The start time of this seat schedule period */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + /** Total number of assigned and unassigned seats in this period */ + fun totalQuantity(totalQuantity: Long) = totalQuantity(JsonField.of(totalQuantity)) + + /** + * Sets [Builder.totalQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.totalQuantity] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalQuantity(totalQuantity: JsonField) = apply { + this.totalQuantity = totalQuantity + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .assignedSeatIds() + * .endingBefore() + * .startingAt() + * .totalQuantity() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("assignedSeatIds", assignedSeatIds).map { it.toImmutable() }, + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + checkRequired("totalQuantity", totalQuantity), + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + assignedSeatIds() + endingBefore() + startingAt() + totalQuantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (assignedSeatIds.asKnown().getOrNull()?.size ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (totalQuantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + assignedSeatIds == other.assignedSeatIds && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + totalQuantity == other.totalQuantity && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + assignedSeatIds, + endingBefore, + startingAt, + totalQuantity, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{assignedSeatIds=$assignedSeatIds, endingBefore=$endingBefore, startingAt=$startingAt, totalQuantity=$totalQuantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContractGetSubscriptionSeatsHistoryResponse && + data == other.data && + nextPage == other.nextPage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextPage, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContractGetSubscriptionSeatsHistoryResponse{data=$data, nextPage=$nextPage, additionalProperties=$additionalProperties}" +} diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParams.kt index 36d02a90..5870bab3 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParams.kt @@ -129,6 +129,15 @@ private constructor( */ fun seatIds(): Optional> = body.seatIds() + /** + * When true, any seat_ids not found in contract subscriptions will be silently omitted from the + * response instead of returning a 400 error. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skipMissingSeatIds(): Optional = body.skipMissingSeatIds() + /** * Include only commits or credits with access effective on or after this date (cannot be used * with covering_date). @@ -211,6 +220,14 @@ private constructor( */ fun _seatIds(): JsonField> = body._seatIds() + /** + * Returns the raw JSON value of [skipMissingSeatIds]. + * + * Unlike [skipMissingSeatIds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _skipMissingSeatIds(): JsonField = body._skipMissingSeatIds() + /** * Returns the raw JSON value of [startingAt]. * @@ -419,6 +436,25 @@ private constructor( */ fun addSeatId(seatId: String) = apply { body.addSeatId(seatId) } + /** + * When true, any seat_ids not found in contract subscriptions will be silently omitted from + * the response instead of returning a 400 error. + */ + fun skipMissingSeatIds(skipMissingSeatIds: Boolean) = apply { + body.skipMissingSeatIds(skipMissingSeatIds) + } + + /** + * Sets [Builder.skipMissingSeatIds] to an arbitrary JSON value. + * + * You should usually call [Builder.skipMissingSeatIds] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skipMissingSeatIds(skipMissingSeatIds: JsonField) = apply { + body.skipMissingSeatIds(skipMissingSeatIds) + } + /** * Include only commits or credits with access effective on or after this date (cannot be * used with covering_date). @@ -620,6 +656,7 @@ private constructor( private val includeLedgers: JsonField, private val limit: JsonField, private val seatIds: JsonField>, + private val skipMissingSeatIds: JsonField, private val startingAt: JsonField, private val subscriptionIds: JsonField>, private val additionalProperties: MutableMap, @@ -650,6 +687,9 @@ private constructor( @JsonProperty("seat_ids") @ExcludeMissing seatIds: JsonField> = JsonMissing.of(), + @JsonProperty("skip_missing_seat_ids") + @ExcludeMissing + skipMissingSeatIds: JsonField = JsonMissing.of(), @JsonProperty("starting_at") @ExcludeMissing startingAt: JsonField = JsonMissing.of(), @@ -666,6 +706,7 @@ private constructor( includeLedgers, limit, seatIds, + skipMissingSeatIds, startingAt, subscriptionIds, mutableMapOf(), @@ -753,6 +794,16 @@ private constructor( */ fun seatIds(): Optional> = seatIds.getOptional("seat_ids") + /** + * When true, any seat_ids not found in contract subscriptions will be silently omitted from + * the response instead of returning a 400 error. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun skipMissingSeatIds(): Optional = + skipMissingSeatIds.getOptional("skip_missing_seat_ids") + /** * Include only commits or credits with access effective on or after this date (cannot be * used with covering_date). @@ -851,6 +902,16 @@ private constructor( */ @JsonProperty("seat_ids") @ExcludeMissing fun _seatIds(): JsonField> = seatIds + /** + * Returns the raw JSON value of [skipMissingSeatIds]. + * + * Unlike [skipMissingSeatIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("skip_missing_seat_ids") + @ExcludeMissing + fun _skipMissingSeatIds(): JsonField = skipMissingSeatIds + /** * Returns the raw JSON value of [startingAt]. * @@ -908,6 +969,7 @@ private constructor( private var includeLedgers: JsonField = JsonMissing.of() private var limit: JsonField = JsonMissing.of() private var seatIds: JsonField>? = null + private var skipMissingSeatIds: JsonField = JsonMissing.of() private var startingAt: JsonField = JsonMissing.of() private var subscriptionIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -923,6 +985,7 @@ private constructor( includeLedgers = body.includeLedgers limit = body.limit seatIds = body.seatIds.map { it.toMutableList() } + skipMissingSeatIds = body.skipMissingSeatIds startingAt = body.startingAt subscriptionIds = body.subscriptionIds.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() @@ -1078,6 +1141,24 @@ private constructor( } } + /** + * When true, any seat_ids not found in contract subscriptions will be silently omitted + * from the response instead of returning a 400 error. + */ + fun skipMissingSeatIds(skipMissingSeatIds: Boolean) = + skipMissingSeatIds(JsonField.of(skipMissingSeatIds)) + + /** + * Sets [Builder.skipMissingSeatIds] to an arbitrary JSON value. + * + * You should usually call [Builder.skipMissingSeatIds] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun skipMissingSeatIds(skipMissingSeatIds: JsonField) = apply { + this.skipMissingSeatIds = skipMissingSeatIds + } + /** * Include only commits or credits with access effective on or after this date (cannot * be used with covering_date). @@ -1168,6 +1249,7 @@ private constructor( includeLedgers, limit, (seatIds ?: JsonMissing.of()).map { it.toImmutable() }, + skipMissingSeatIds, startingAt, (subscriptionIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -1199,6 +1281,7 @@ private constructor( includeLedgers() limit() seatIds() + skipMissingSeatIds() startingAt() subscriptionIds() validated = true @@ -1229,6 +1312,7 @@ private constructor( (if (includeLedgers.asKnown().isPresent) 1 else 0) + (if (limit.asKnown().isPresent) 1 else 0) + (seatIds.asKnown().getOrNull()?.size ?: 0) + + (if (skipMissingSeatIds.asKnown().isPresent) 1 else 0) + (if (startingAt.asKnown().isPresent) 1 else 0) + (subscriptionIds.asKnown().getOrNull()?.size ?: 0) @@ -1247,6 +1331,7 @@ private constructor( includeLedgers == other.includeLedgers && limit == other.limit && seatIds == other.seatIds && + skipMissingSeatIds == other.skipMissingSeatIds && startingAt == other.startingAt && subscriptionIds == other.subscriptionIds && additionalProperties == other.additionalProperties @@ -1263,6 +1348,7 @@ private constructor( includeLedgers, limit, seatIds, + skipMissingSeatIds, startingAt, subscriptionIds, additionalProperties, @@ -1272,7 +1358,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{contractId=$contractId, customerId=$customerId, coveringDate=$coveringDate, cursor=$cursor, effectiveBefore=$effectiveBefore, includeCreditsAndCommits=$includeCreditsAndCommits, includeLedgers=$includeLedgers, limit=$limit, seatIds=$seatIds, startingAt=$startingAt, subscriptionIds=$subscriptionIds, additionalProperties=$additionalProperties}" + "Body{contractId=$contractId, customerId=$customerId, coveringDate=$coveringDate, cursor=$cursor, effectiveBefore=$effectiveBefore, includeCreditsAndCommits=$includeCreditsAndCommits, includeLedgers=$includeLedgers, limit=$limit, seatIds=$seatIds, skipMissingSeatIds=$skipMissingSeatIds, startingAt=$startingAt, subscriptionIds=$subscriptionIds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ratecards/rates/RateAddParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ratecards/rates/RateAddParams.kt index 0a14e788..f8b892bc 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ratecards/rates/RateAddParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/contracts/ratecards/rates/RateAddParams.kt @@ -25,7 +25,13 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Add a new rate */ +/** + * Add a new rate + * + * This endpoint is heavily rate limited. For adding multiple rates, using the + * [addRates](https://docs.metronome.com/api-reference/rate-cards/add-rates) endpoint is strongly + * encouraged. + */ class RateAddParams private constructor( private val body: Body, diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParams.kt index 7163ab5a..6ecba5f6 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParams.kt @@ -48,11 +48,11 @@ import kotlin.jvm.optionals.getOrNull * - `null` - Notification has been archived * - `triggered_by`: Additional context about what caused the notification to trigger (when * applicable) + * - `updated_at`: Timestamp of when the `customer_status` was last updated * - alert: Complete threshold notification configuration including: * - Notification ID, name, and type * - Current threshold values and credit type information * - Notification status (enabled, disabled, or archived) - * - Last update timestamp * - Any applied filters (credit grant types, custom fields, group values) * * ### Usage guidelines: @@ -92,6 +92,15 @@ private constructor( */ fun customerId(): String = body.customerId() + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Used to filter the alert by the custom field key-value pair. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alertSpecifiers(): Optional> = body.alertSpecifiers() + /** * Only present for `spend_threshold_reached` notifications. Retrieve the notification for a * specific group key-value pair. @@ -133,6 +142,13 @@ private constructor( */ fun _customerId(): JsonField = body._customerId() + /** + * Returns the raw JSON value of [alertSpecifiers]. + * + * Unlike [alertSpecifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _alertSpecifiers(): JsonField> = body._alertSpecifiers() + /** * Returns the raw JSON value of [groupValues]. * @@ -200,9 +216,9 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [alertId] * - [customerId] + * - [alertSpecifiers] * - [groupValues] * - [plansOrContracts] - * - [seatFilter] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -230,6 +246,34 @@ private constructor( */ fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Used to filter the alert by the custom field key-value pair. + */ + fun alertSpecifiers(alertSpecifiers: List) = apply { + body.alertSpecifiers(alertSpecifiers) + } + + /** + * Sets [Builder.alertSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.alertSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun alertSpecifiers(alertSpecifiers: JsonField>) = apply { + body.alertSpecifiers(alertSpecifiers) + } + + /** + * Adds a single [AlertSpecifier] to [alertSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlertSpecifier(alertSpecifier: AlertSpecifier) = apply { + body.addAlertSpecifier(alertSpecifier) + } + /** * Only present for `spend_threshold_reached` notifications. Retrieve the notification for a * specific group key-value pair. @@ -437,6 +481,7 @@ private constructor( private constructor( private val alertId: JsonField, private val customerId: JsonField, + private val alertSpecifiers: JsonField>, private val groupValues: JsonField>, private val plansOrContracts: JsonField, private val seatFilter: JsonField, @@ -449,6 +494,9 @@ private constructor( @JsonProperty("customer_id") @ExcludeMissing customerId: JsonField = JsonMissing.of(), + @JsonProperty("alert_specifiers") + @ExcludeMissing + alertSpecifiers: JsonField> = JsonMissing.of(), @JsonProperty("group_values") @ExcludeMissing groupValues: JsonField> = JsonMissing.of(), @@ -458,7 +506,15 @@ private constructor( @JsonProperty("seat_filter") @ExcludeMissing seatFilter: JsonField = JsonMissing.of(), - ) : this(alertId, customerId, groupValues, plansOrContracts, seatFilter, mutableMapOf()) + ) : this( + alertId, + customerId, + alertSpecifiers, + groupValues, + plansOrContracts, + seatFilter, + mutableMapOf(), + ) /** * The Metronome ID of the threshold notification @@ -476,6 +532,16 @@ private constructor( */ fun customerId(): String = customerId.getRequired("customer_id") + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Used to filter the alert by the custom field key-value pair. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alertSpecifiers(): Optional> = + alertSpecifiers.getOptional("alert_specifiers") + /** * Only present for `spend_threshold_reached` notifications. Retrieve the notification for a * specific group key-value pair. @@ -520,6 +586,16 @@ private constructor( @ExcludeMissing fun _customerId(): JsonField = customerId + /** + * Returns the raw JSON value of [alertSpecifiers]. + * + * Unlike [alertSpecifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("alert_specifiers") + @ExcludeMissing + fun _alertSpecifiers(): JsonField> = alertSpecifiers + /** * Returns the raw JSON value of [groupValues]. * @@ -579,6 +655,7 @@ private constructor( private var alertId: JsonField? = null private var customerId: JsonField? = null + private var alertSpecifiers: JsonField>? = null private var groupValues: JsonField>? = null private var plansOrContracts: JsonField = JsonMissing.of() private var seatFilter: JsonField = JsonMissing.of() @@ -588,6 +665,7 @@ private constructor( internal fun from(body: Body) = apply { alertId = body.alertId customerId = body.customerId + alertSpecifiers = body.alertSpecifiers.map { it.toMutableList() } groupValues = body.groupValues.map { it.toMutableList() } plansOrContracts = body.plansOrContracts seatFilter = body.seatFilter @@ -618,6 +696,36 @@ private constructor( */ fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** + * Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` + * notifications. Used to filter the alert by the custom field key-value pair. + */ + fun alertSpecifiers(alertSpecifiers: List) = + alertSpecifiers(JsonField.of(alertSpecifiers)) + + /** + * Sets [Builder.alertSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.alertSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun alertSpecifiers(alertSpecifiers: JsonField>) = apply { + this.alertSpecifiers = alertSpecifiers.map { it.toMutableList() } + } + + /** + * Adds a single [AlertSpecifier] to [alertSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlertSpecifier(alertSpecifier: AlertSpecifier) = apply { + alertSpecifiers = + (alertSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("alertSpecifiers", it).add(alertSpecifier) + } + } + /** * Only present for `spend_threshold_reached` notifications. Retrieve the notification * for a specific group key-value pair. @@ -718,6 +826,7 @@ private constructor( Body( checkRequired("alertId", alertId), checkRequired("customerId", customerId), + (alertSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, (groupValues ?: JsonMissing.of()).map { it.toImmutable() }, plansOrContracts, seatFilter, @@ -743,6 +852,7 @@ private constructor( alertId() customerId() + alertSpecifiers().ifPresent { it.forEach { it.validate() } } groupValues().ifPresent { it.forEach { it.validate() } } plansOrContracts().ifPresent { it.validate() } seatFilter().ifPresent { it.validate() } @@ -767,6 +877,7 @@ private constructor( internal fun validity(): Int = (if (alertId.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + + (alertSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (groupValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (plansOrContracts.asKnown().getOrNull()?.validity() ?: 0) + (seatFilter.asKnown().getOrNull()?.validity() ?: 0) @@ -779,6 +890,7 @@ private constructor( return other is Body && alertId == other.alertId && customerId == other.customerId && + alertSpecifiers == other.alertSpecifiers && groupValues == other.groupValues && plansOrContracts == other.plansOrContracts && seatFilter == other.seatFilter && @@ -789,6 +901,7 @@ private constructor( Objects.hash( alertId, customerId, + alertSpecifiers, groupValues, plansOrContracts, seatFilter, @@ -799,7 +912,1252 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{alertId=$alertId, customerId=$customerId, groupValues=$groupValues, plansOrContracts=$plansOrContracts, seatFilter=$seatFilter, additionalProperties=$additionalProperties}" + "Body{alertId=$alertId, customerId=$customerId, alertSpecifiers=$alertSpecifiers, groupValues=$groupValues, plansOrContracts=$plansOrContracts, seatFilter=$seatFilter, additionalProperties=$additionalProperties}" + } + + class AlertSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of(), + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of(), + ) : this(customFieldFilters, exclude, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customFieldFilters(): List = + customFieldFilters.getRequired("custom_field_filters") + + /** + * If provided, the specifier will not apply to balances that matches the inclusion criteria + * and any of the excluding values. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exclude(): Optional> = exclude.getOptional("exclude") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exclude") @ExcludeMissing fun _exclude(): JsonField> = exclude + + @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 [AlertSpecifier]. + * + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertSpecifier]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = null + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(alertSpecifier: AlertSpecifier) = apply { + customFieldFilters = alertSpecifier.customFieldFilters.map { it.toMutableList() } + exclude = alertSpecifier.exclude.map { it.toMutableList() } + additionalProperties = alertSpecifier.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + /** + * If provided, the specifier will not apply to balances that matches the inclusion + * criteria and any of the excluding values. + */ + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + + /** + * Sets [Builder.exclude] to an arbitrary JSON value. + * + * You should usually call [Builder.exclude] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AlertSpecifier = + AlertSpecifier( + checkRequired("customFieldFilters", customFieldFilters).map { + it.toImmutable() + }, + (exclude ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AlertSpecifier = apply { + if (validated) { + return@apply + } + + customFieldFilters().forEach { it.validate() } + exclude().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + class Exclude + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customFieldFilters(): Optional> = + customFieldFilters.getOptional("custom_field_filters") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + @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 [Exclude]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Exclude]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(exclude: Exclude) = apply { + customFieldFilters = exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced + * filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = + apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Exclude]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Exclude = + Exclude( + (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Exclude = apply { + if (validated) { + return@apply + } + + customFieldFilters().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Exclude && + customFieldFilters == other.customFieldFilters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertSpecifier && + customFieldFilters == other.customFieldFilters && + exclude == other.exclude && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, exclude, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertSpecifier{customFieldFilters=$customFieldFilters, exclude=$exclude, additionalProperties=$additionalProperties}" } /** diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlert.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlert.kt index 70823691..ea507407 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlert.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlert.kt @@ -269,6 +269,7 @@ private constructor( private val threshold: JsonField, private val type: JsonField, private val updatedAt: JsonField, + private val alertSpecifiers: JsonField>, private val creditGrantTypeFilters: JsonField>, private val creditType: JsonField, private val customFieldFilters: JsonField>, @@ -292,6 +293,9 @@ private constructor( @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("alert_specifiers") + @ExcludeMissing + alertSpecifiers: JsonField> = JsonMissing.of(), @JsonProperty("credit_grant_type_filters") @ExcludeMissing creditGrantTypeFilters: JsonField> = JsonMissing.of(), @@ -323,6 +327,7 @@ private constructor( threshold, type, updatedAt, + alertSpecifiers, creditGrantTypeFilters, creditType, customFieldFilters, @@ -375,13 +380,23 @@ private constructor( fun type(): Type = type.getRequired("type") /** - * Timestamp for when the threshold notification was last updated + * Timestamp for when the threshold notification's customer status was last updated * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + /** + * Present for `low_remaining_contract_credit_and_commit_balance_reached` notifications. The + * filters that define the balances that are considered when evaluating the alert. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun alertSpecifiers(): Optional> = + alertSpecifiers.getOptional("alert_specifiers") + /** * An array of strings, representing a way to filter the credit grant this threshold * notification applies to, by looking at the credit_grant_type field on the credit grant. @@ -500,6 +515,16 @@ private constructor( @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + /** + * Returns the raw JSON value of [alertSpecifiers]. + * + * Unlike [alertSpecifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("alert_specifiers") + @ExcludeMissing + fun _alertSpecifiers(): JsonField> = alertSpecifiers + /** * Returns the raw JSON value of [creditGrantTypeFilters]. * @@ -616,6 +641,7 @@ private constructor( private var threshold: JsonField? = null private var type: JsonField? = null private var updatedAt: JsonField? = null + private var alertSpecifiers: JsonField>? = null private var creditGrantTypeFilters: JsonField>? = null private var creditType: JsonField = JsonMissing.of() private var customFieldFilters: JsonField>? = null @@ -634,6 +660,7 @@ private constructor( threshold = alert.threshold type = alert.type updatedAt = alert.updatedAt + alertSpecifiers = alert.alertSpecifiers.map { it.toMutableList() } creditGrantTypeFilters = alert.creditGrantTypeFilters.map { it.toMutableList() } creditType = alert.creditType customFieldFilters = alert.customFieldFilters.map { it.toMutableList() } @@ -705,7 +732,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } - /** Timestamp for when the threshold notification was last updated */ + /** Timestamp for when the threshold notification's customer status was last updated */ fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) /** @@ -719,6 +746,36 @@ private constructor( this.updatedAt = updatedAt } + /** + * Present for `low_remaining_contract_credit_and_commit_balance_reached` notifications. + * The filters that define the balances that are considered when evaluating the alert. + */ + fun alertSpecifiers(alertSpecifiers: List) = + alertSpecifiers(JsonField.of(alertSpecifiers)) + + /** + * Sets [Builder.alertSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.alertSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun alertSpecifiers(alertSpecifiers: JsonField>) = apply { + this.alertSpecifiers = alertSpecifiers.map { it.toMutableList() } + } + + /** + * Adds a single [AlertSpecifier] to [alertSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAlertSpecifier(alertSpecifier: AlertSpecifier) = apply { + alertSpecifiers = + (alertSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("alertSpecifiers", it).add(alertSpecifier) + } + } + /** * An array of strings, representing a way to filter the credit grant this threshold * notification applies to, by looking at the credit_grant_type field on the credit @@ -954,6 +1011,7 @@ private constructor( checkRequired("threshold", threshold), checkRequired("type", type), checkRequired("updatedAt", updatedAt), + (alertSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, (creditGrantTypeFilters ?: JsonMissing.of()).map { it.toImmutable() }, creditType, (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, @@ -988,6 +1046,7 @@ private constructor( threshold() type().validate() updatedAt() + alertSpecifiers().ifPresent { it.forEach { it.validate() } } creditGrantTypeFilters() creditType().ifPresent { it.validate() } customFieldFilters().ifPresent { it.forEach { it.validate() } } @@ -1021,6 +1080,7 @@ private constructor( (if (threshold.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (alertSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (creditGrantTypeFilters.asKnown().getOrNull()?.size ?: 0) + (creditType.asKnown().getOrNull()?.validity() ?: 0) + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -1430,6 +1490,1261 @@ private constructor( override fun toString() = value.toString() } + class AlertSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of(), + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of(), + ) : this(customFieldFilters, exclude, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customFieldFilters(): Optional> = + customFieldFilters.getOptional("custom_field_filters") + + /** + * If provided, the specifier will not apply to balances that matches the inclusion + * criteria and any of the excluding values. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exclude(): Optional> = exclude.getOptional("exclude") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exclude") + @ExcludeMissing + fun _exclude(): JsonField> = exclude + + @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 [AlertSpecifier]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertSpecifier]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = null + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(alertSpecifier: AlertSpecifier) = apply { + customFieldFilters = + alertSpecifier.customFieldFilters.map { it.toMutableList() } + exclude = alertSpecifier.exclude.map { it.toMutableList() } + additionalProperties = alertSpecifier.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced + * filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = + apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + /** + * If provided, the specifier will not apply to balances that matches the inclusion + * criteria and any of the excluding values. + */ + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + + /** + * Sets [Builder.exclude] to an arbitrary JSON value. + * + * You should usually call [Builder.exclude] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AlertSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AlertSpecifier = + AlertSpecifier( + (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, + (exclude ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AlertSpecifier = apply { + if (validated) { + return@apply + } + + customFieldFilters().ifPresent { it.forEach { it.validate() } } + exclude().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + value, + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + class Exclude + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) + + /** + * A list of custom field filters for notification types that support advanced + * filtering + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun customFieldFilters(): Optional> = + customFieldFilters.getOptional("custom_field_filters") + + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters + + @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 [Exclude]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Exclude]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(exclude: Exclude) = apply { + customFieldFilters = exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() + } + + /** + * A list of custom field filters for notification types that support advanced + * filtering + */ + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) + + /** + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun customFieldFilters(customFieldFilters: JsonField>) = + apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Exclude]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Exclude = + Exclude( + (customFieldFilters ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Exclude = apply { + if (validated) { + return@apply + } + + customFieldFilters().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") + @ExcludeMissing + key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun entity(): Entity = entity.getRequired("entity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun key(): String = key.getRequired("key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [entity]. + * + * Unlike [entity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("entity") + @ExcludeMissing + fun _entity(): JsonField = entity + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = + customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CONTRACT = of("Contract") + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Entity] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTRACT, + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTRACT -> Value.CONTRACT + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CONTRACT -> Known.CONTRACT + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> + throw MetronomeInvalidDataException("Unknown Entity: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entity && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Exclude && + customFieldFilters == other.customFieldFilters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AlertSpecifier && + customFieldFilters == other.customFieldFilters && + exclude == other.exclude && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, exclude, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertSpecifier{customFieldFilters=$customFieldFilters, exclude=$exclude, additionalProperties=$additionalProperties}" + } + class CustomFieldFilter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2485,6 +3800,7 @@ private constructor( threshold == other.threshold && type == other.type && updatedAt == other.updatedAt && + alertSpecifiers == other.alertSpecifiers && creditGrantTypeFilters == other.creditGrantTypeFilters && creditType == other.creditType && customFieldFilters == other.customFieldFilters && @@ -2504,6 +3820,7 @@ private constructor( threshold, type, updatedAt, + alertSpecifiers, creditGrantTypeFilters, creditType, customFieldFilters, @@ -2519,7 +3836,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Alert{id=$id, name=$name, status=$status, threshold=$threshold, type=$type, updatedAt=$updatedAt, creditGrantTypeFilters=$creditGrantTypeFilters, creditType=$creditType, customFieldFilters=$customFieldFilters, groupKeyFilter=$groupKeyFilter, groupValues=$groupValues, invoiceTypesFilter=$invoiceTypesFilter, seatFilter=$seatFilter, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" + "Alert{id=$id, name=$name, status=$status, threshold=$threshold, type=$type, updatedAt=$updatedAt, alertSpecifiers=$alertSpecifiers, creditGrantTypeFilters=$creditGrantTypeFilters, creditType=$creditType, customFieldFilters=$customFieldFilters, groupKeyFilter=$groupKeyFilter, groupValues=$groupValues, invoiceTypesFilter=$invoiceTypesFilter, seatFilter=$seatFilter, uniquenessKey=$uniquenessKey, additionalProperties=$additionalProperties}" } /** diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParams.kt index 34be5944..79e5bc3c 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParams.kt @@ -63,6 +63,7 @@ private constructor( private val startingOn: OffsetDateTime?, private val status: String?, private val type: Type?, + private val webhookNotificationId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -105,6 +106,11 @@ private constructor( /** Filter invoices by type. Defaults to returning all invoice types. */ fun type(): Optional = Optional.ofNullable(type) + /** + * Indicates that this API request was triggered by a webhook notification with the provided ID. + */ + fun webhookNotificationId(): Optional = Optional.ofNullable(webhookNotificationId) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -140,6 +146,7 @@ private constructor( private var startingOn: OffsetDateTime? = null private var status: String? = null private var type: Type? = null + private var webhookNotificationId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -156,6 +163,7 @@ private constructor( startingOn = invoiceListParams.startingOn status = invoiceListParams.status type = invoiceListParams.type + webhookNotificationId = invoiceListParams.webhookNotificationId additionalHeaders = invoiceListParams.additionalHeaders.toBuilder() additionalQueryParams = invoiceListParams.additionalQueryParams.toBuilder() } @@ -250,6 +258,21 @@ private constructor( /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Indicates that this API request was triggered by a webhook notification with the provided + * ID. + */ + fun webhookNotificationId(webhookNotificationId: String?) = apply { + this.webhookNotificationId = webhookNotificationId + } + + /** + * Alias for calling [Builder.webhookNotificationId] with + * `webhookNotificationId.orElse(null)`. + */ + fun webhookNotificationId(webhookNotificationId: Optional) = + webhookNotificationId(webhookNotificationId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -373,6 +396,7 @@ private constructor( startingOn, status, type, + webhookNotificationId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -403,6 +427,7 @@ private constructor( } status?.let { put("status", it) } type?.let { put("type", it.toString()) } + webhookNotificationId?.let { put("webhook_notification_id", it) } putAll(additionalQueryParams) } .build() @@ -704,6 +729,7 @@ private constructor( startingOn == other.startingOn && status == other.status && type == other.type && + webhookNotificationId == other.webhookNotificationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } @@ -721,10 +747,11 @@ private constructor( startingOn, status, type, + webhookNotificationId, additionalHeaders, additionalQueryParams, ) override fun toString() = - "InvoiceListParams{customerId=$customerId, contractId=$contractId, creditTypeId=$creditTypeId, endingBefore=$endingBefore, limit=$limit, nextPage=$nextPage, skipZeroQtyLineItems=$skipZeroQtyLineItems, sort=$sort, startingOn=$startingOn, status=$status, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InvoiceListParams{customerId=$customerId, contractId=$contractId, creditTypeId=$creditTypeId, endingBefore=$endingBefore, limit=$limit, nextPage=$nextPage, skipZeroQtyLineItems=$skipZeroQtyLineItems, sort=$sort, startingOn=$startingOn, status=$status, type=$type, webhookNotificationId=$webhookNotificationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageCreateParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageCreateParams.kt index 08e45da2..931f6f3f 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageCreateParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageCreateParams.kt @@ -8971,9 +8971,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing `commit_ids`, + * `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not specify any of these + * fields, the override will apply when consuming any prepaid commit, postpaid commit, or + * credit * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -9254,9 +9255,10 @@ private constructor( /** * Indicates whether the override should only apply to commits. Defaults to `false`. If - * `true`, you can specify relevant commits in `override_specifiers` by passing - * `commit_ids`. if you do not specify `commit_ids`, then the override will apply when - * consuming any prepaid or postpaid commit. + * `true` you can specify relevant commits in `override_specifiers` by passing + * `commit_ids`, `recurring_commit_ids`, or `any_commit_or_credit_ids`. If you do not + * specify any of these fields, the override will apply when consuming any prepaid + * commit, postpaid commit, or credit */ fun isCommitSpecific(isCommitSpecific: Boolean) = isCommitSpecific(JsonField.of(isCommitSpecific)) @@ -9482,6 +9484,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -9494,6 +9497,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -9516,6 +9522,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -9526,6 +9533,19 @@ private constructor( mutableMapOf(), ) + /** + * Can only be used for commit specific overrides. Must be used in conjunction with one + * of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified commit, + * credit, recurring commit or recurring credit IDs. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9592,6 +9612,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -9686,6 +9716,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -9698,6 +9729,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -9709,6 +9742,39 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + /** + * Can only be used for commit specific overrides. Must be used in conjunction with + * one of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified + * commit, credit, recurring commit or recurring credit IDs. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -9894,6 +9960,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -9922,6 +9989,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -9948,7 +10016,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -10369,6 +10438,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -10381,6 +10451,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -10395,7 +10466,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } /** @@ -12630,6 +12701,7 @@ private constructor( private val invoiceAmount: JsonField, private val name: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, @@ -12675,6 +12747,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), @@ -12706,6 +12781,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -12817,6 +12893,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Optional rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * Whether the created commits will use the commit rate or list rate * @@ -12982,6 +13067,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [rateType]. * @@ -13081,6 +13176,7 @@ private constructor( private var invoiceAmount: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -13105,6 +13201,7 @@ private constructor( invoiceAmount = recurringCommit.invoiceAmount name = recurringCommit.name proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding rateType = recurringCommit.rateType recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction @@ -13313,6 +13410,21 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Optional rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** Whether the created commits will use the commit rate or list rate */ fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -13477,6 +13589,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -13515,6 +13628,7 @@ private constructor( invoiceAmount().ifPresent { it.validate() } name() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() @@ -13552,6 +13666,7 @@ private constructor( (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + @@ -15308,97 +15423,138 @@ private constructor( override fun toString() = value.toString() } - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Optional rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun access(): Optional = access.getOptional("access") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - @JvmField val LIST_RATE = of("LIST_RATE") + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_RATE, - LIST_RATE, /** - * An enum member indicating that [RateType] was instantiated with an unknown value. + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -15411,12 +15567,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -15434,523 +15591,529 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RateType && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val QUARTERLY = of("QUARTERLY") + fun toBuilder() = Builder().from(this) - @JvmField val ANNUAL = of("ANNUAL") + companion object { - @JvmField val WEEKLY = of("WEEKLY") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) - } + /** A builder for [Access]. */ + class Builder internal constructor() { - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - private var validated: Boolean = false + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RecurrenceFrequency = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - known() - validated = true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - return other is RecurrenceFrequency && value == other.value - } + private var validated: Boolean = false - override fun hashCode() = value.hashCode() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - override fun toString() = value.toString() - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val applySeatIncreaseConfig: JsonField, - private val subscriptionId: JsonField, - private val allocation: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_id") - @ExcludeMissing - subscriptionId: JsonField = JsonMissing.of(), - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * ID of the subscription to configure on the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun allocation(): Optional = allocation.getOptional("allocation") + companion object { - /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns the raw JSON value of [subscriptionId]. - * - * Unlike [subscriptionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_id") - @ExcludeMissing - fun _subscriptionId(): JsonField = subscriptionId + @JvmField val FLOOR = of("FLOOR") - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + @JvmField val CEILING = of("CEILING") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - fun toBuilder() = Builder().from(this) + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionId: JsonField? = null - private var allocation: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionId = subscriptionConfig.subscriptionId - allocation = subscriptionConfig.allocation - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - - /** ID of the subscription to configure on the recurring commit/credit. */ - fun subscriptionId(subscriptionId: String) = - subscriptionId(JsonField.of(subscriptionId)) + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Sets [Builder.subscriptionId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun subscriptionId(subscriptionId: JsonField) = apply { - this.subscriptionId = subscriptionId - } + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") /** - * If set to POOLED, allocation added per seat is pooled across the account. If set - * to INDIVIDUAL, each seat in the subscription will have its own allocation. + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Returns the raw JSON value of [roundingMethod]. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionId", subscriptionId), - allocation, - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply - } - - applySeatIncreaseConfig().validate() - subscriptionId() - allocation().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionId.asKnown().isPresent) 1 else 0) + - (allocation.asKnown().getOrNull()?.validity() ?: 0) - - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) - - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated - - @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 - * [ApplySeatIncreaseConfig]. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ApplySeatIncreaseConfig]. */ - class Builder internal constructor() { - - private var isProrated: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() - } - - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = apply { @@ -15976,20 +16139,22 @@ private constructor( } /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -16006,12 +16171,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ApplySeatIncreaseConfig = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - isProrated() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -16030,170 +16196,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" - } + @JvmField val HALF_UP = of("HALF_UP") - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - */ - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val FLOOR = of("FLOOR") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmField val CEILING = of("CEILING") - companion object { + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - @JvmField val POOLED = of("POOLED") + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - INDIVIDUAL, - POOLED, - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Allocation] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - POOLED, /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - _UNKNOWN, - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED - else -> Value._UNKNOWN - } + private var validated: Boolean = false - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is RoundingMethod && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Allocation && value == other.value + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -16201,1368 +16381,2673 @@ private constructor( return true } - return other is SubscriptionConfig && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionId == other.subscriptionId && - allocation == other.allocation && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - applySeatIncreaseConfig, - subscriptionId, - allocation, - additionalProperties, - ) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is RecurringCommit && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - productId == other.productId && - startingAtOffset == other.startingAtOffset && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - duration == other.duration && - invoiceAmount == other.invoiceAmount && - name == other.name && - proration == other.proration && - rateType == other.rateType && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - temporaryId == other.temporaryId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - accessAmount, - commitDuration, - priority, - productId, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - invoiceAmount, - name, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - override fun toString() = - "RecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" - } + @JvmField val LIST_RATE = of("LIST_RATE") - class RecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val startingAtOffset: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val duration: JsonField, - private val name: JsonField, - private val proration: JsonField, - private val rateType: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - @JsonCreator - private constructor( - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") - @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") - @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") - @ExcludeMissing - subscriptionConfig: JsonField = JsonMissing.of(), - @JsonProperty("temporary_id") - @ExcludeMissing - temporaryId: JsonField = JsonMissing.of(), - ) : this( - accessAmount, - commitDuration, - priority, - productId, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - name, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - mutableMapOf(), - ) + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } - /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a period - * is determined by the recurrence_frequency. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priority(): Double = priority.getRequired("priority") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun productId(): String = productId.getRequired("product_id") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Offset relative to the contract start date that determines the start time for the first - * commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun startingAtOffset(): StartingAtOffset = - startingAtOffset.getRequired("starting_at_offset") + private var validated: Boolean = false - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + known() + validated = true + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Offset relative to the recurring credit start that determines when the contract will stop - * creating recurring commits. optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * displayed on invoices. will be passed through to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun proration(): Optional = proration.getOptional("proration") + return other is RateType && value == other.value + } - /** - * Whether the created commits will use the commit rate or list rate - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined * in the duration will correspond to this frequency. - Commits will be created aligned with * the recurring commit's starting_at rather than the usage invoice dates. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Will be passed down to the individual commits. This controls how much of an individual - * unexpired commit will roll over upon contract transition. Must be between 0 and 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * List of filters that determine what kind of customer usage draws down a commit or credit. - * A customer's usage needs to meet the condition of at least one of the specifiers to - * contribute to a commit's or credit's drawdown. This field cannot be used together with - * `applicable_product_ids` or `applicable_product_tags`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + companion object { - /** - * Attach a subscription to the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") + @JvmField val MONTHLY = of("MONTHLY") - /** - * A temporary ID that can be used to reference the recurring commit for commit specific - * overrides. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + @JvmField val QUARTERLY = of("QUARTERLY") - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount + @JvmField val ANNUAL = of("ANNUAL") - /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + @JvmField val WEEKLY = of("WEEKLY") - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + @JvmField val DAILY = of("DAILY") - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + private var validated: Boolean = false - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + known() + validated = true + } - /** - * Returns the raw JSON value of [recurrenceFrequency]. - * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recurrence_frequency") - @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") - @ExcludeMissing - fun _subscriptionConfig(): JsonField = subscriptionConfig + return other is RecurrenceFrequency && value == other.value + } - /** - * Returns the raw JSON value of [temporaryId]. - * - * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("temporary_id") - @ExcludeMissing - fun _temporaryId(): JsonField = temporaryId + override fun hashCode() = value.hashCode() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun toString() = value.toString() } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applySeatIncreaseConfig: JsonField, + private val subscriptionId: JsonField, + private val allocation: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) /** - * Returns a mutable builder for constructing an instance of [RecurringCredit]. - * - * The following fields are required: - * ```java - * .accessAmount() - * .commitDuration() - * .priority() - * .productId() - * .startingAtOffset() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecurringCredit]. */ - class Builder internal constructor() { - - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var productId: JsonField? = null - private var startingAtOffset: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = JsonMissing.of() - private var temporaryId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(recurringCredit: RecurringCredit) = apply { - accessAmount = recurringCredit.accessAmount - commitDuration = recurringCredit.commitDuration - priority = recurringCredit.priority - productId = recurringCredit.productId - startingAtOffset = recurringCredit.startingAtOffset - applicableProductIds = - recurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - recurringCredit.applicableProductTags.map { it.toMutableList() } - description = recurringCredit.description - duration = recurringCredit.duration - name = recurringCredit.name - proration = recurringCredit.proration - rateType = recurringCredit.rateType - recurrenceFrequency = recurringCredit.recurrenceFrequency - rolloverFraction = recurringCredit.rolloverFraction - specifiers = recurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = recurringCredit.subscriptionConfig - temporaryId = recurringCredit.temporaryId - additionalProperties = recurringCredit.additionalProperties.toMutableMap() - } - - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. + * ID of the subscription to configure on the recurring commit/credit. * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } - - /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a - * period is determined by the recurrence_frequency. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. * - * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration - } - - /** Will be passed down to the individual commits */ - fun priority(priority: Double) = priority(JsonField.of(priority)) + fun allocation(): Optional = allocation.getOptional("allocation") /** - * Sets [Builder.priority] to an arbitrary JSON value. + * Returns the raw JSON value of [applySeatIncreaseConfig]. * - * You should usually call [Builder.priority] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun priority(priority: JsonField) = apply { this.priority = priority } - - fun productId(productId: String) = productId(JsonField.of(productId)) + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig /** - * Sets [Builder.productId] to an arbitrary JSON value. + * Returns the raw JSON value of [subscriptionId]. * - * You should usually call [Builder.productId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } - - /** - * Offset relative to the contract start date that determines the start time for the - * first commit + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * Returns the raw JSON value of [allocation]. * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset - } - - /** Will be passed down to the individual commits */ - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Will be passed down to the individual commits */ - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + companion object { - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } + /** + * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** Will be passed down to the individual commits */ - fun description(description: String) = description(JsonField.of(description)) + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Offset relative to the recurring credit start that determines when the contract will - * stop creating recurring commits. optional - */ - fun duration(duration: Duration) = duration(JsonField.of(duration)) + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionId = subscriptionConfig.subscriptionId + allocation = subscriptionConfig.allocation + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) - /** displayed on invoices. will be passed through to the individual commits */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** ID of the subscription to configure on the recurring commit/credit. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set + * to INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { - this.recurrenceFrequency = recurrenceFrequency - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be between - * 0 and 1. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionId", subscriptionId), + allocation, + additionalProperties.toMutableMap(), + ) } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - */ - fun specifiers(specifiers: List) = - specifiers(JsonField.of(specifiers)) + private var validated: Boolean = false /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } - - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } - - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [SubscriptionConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun subscriptionConfig(subscriptionConfig: JsonField) = apply { - this.subscriptionConfig = subscriptionConfig + applySeatIncreaseConfig().validate() + subscriptionId() + allocation().ifPresent { it.validate() } + validated = true } - /** - * A temporary ID that can be used to reference the recurring commit for commit specific - * overrides. - */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } + @JvmSynthetic + internal fun validity(): Int = + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (allocation.asKnown().getOrNull()?.validity() ?: 0) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated - /** - * Returns an immutable instance of [RecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessAmount() - * .commitDuration() - * .priority() - * .productId() - * .startingAtOffset() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RecurringCredit = - RecurringCredit( - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("productId", productId), - checkRequired("startingAtOffset", startingAtOffset), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - duration, - name, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - temporaryId, - additionalProperties.toMutableMap(), - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): RecurringCredit = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - accessAmount().validate() - commitDuration().validate() - priority() - productId() - startingAtOffset().validate() - applicableProductIds() - applicableProductTags() - description() - duration().ifPresent { it.validate() } - name() - proration().ifPresent { it.validate() } - rateType().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - temporaryId() - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } - /** - * This field is required unless a subscription is attached via `subscription_config`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [AccessAmount]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + isProrated() + validated = true + } - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmField val POOLED = of("POOLED") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * This field is required unless a subscription is attached via - * `subscription_config`. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN + } /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply + return other is Allocation && value == other.value } - creditTypeId() - unitPrice() - quantity() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && + return other is SubscriptionConfig && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionId == other.subscriptionId && + allocation == other.allocation && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + Objects.hash( + applySeatIncreaseConfig, + subscriptionId, + allocation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" } - /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a period - * is determined by the recurrence_frequency. - */ - class CommitDuration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val value: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): Double = value.getRequired("value") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - - @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 [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [CommitDuration]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() - } - - fun value(value: Double) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + return other is RecurringCommit && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + productId == other.productId && + startingAtOffset == other.startingAtOffset && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + duration == other.duration && + invoiceAmount == other.invoiceAmount && + name == other.name && + proration == other.proration && + prorationRounding == other.prorationRounding && + rateType == other.rateType && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + temporaryId == other.temporaryId && + additionalProperties == other.additionalProperties + } - fun unit(unit: Unit) = unit(JsonField.of(unit)) + private val hashCode: Int by lazy { + Objects.hash( + accessAmount, + commitDuration, + priority, + productId, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + invoiceAmount, + name, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + additionalProperties, + ) + } - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + override fun hashCode(): Int = hashCode - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun toString() = + "RecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class RecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val startingAtOffset: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val duration: JsonField, + private val name: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JsonCreator + private constructor( + @JsonProperty("access_amount") + @ExcludeMissing + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = JsonMissing.of(), + @JsonProperty("temporary_id") + @ExcludeMissing + temporaryId: JsonField = JsonMissing.of(), + ) : this( + accessAmount, + commitDuration, + priority, + productId, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + name, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + mutableMapOf(), + ) + + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a period + * is determined by the recurrence_frequency. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priority(): Double = priority.getRequired("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun productId(): String = productId.getRequired("product_id") + + /** + * Offset relative to the contract start date that determines the start time for the first + * commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingAtOffset(): StartingAtOffset = + startingAtOffset.getRequired("starting_at_offset") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Offset relative to the recurring credit start that determines when the contract will stop + * creating recurring commits. optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * displayed on invoices. will be passed through to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") + + /** + * Optional rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") + + /** + * Will be passed down to the individual commits. This controls how much of an individual + * unexpired commit will roll over upon contract transition. Must be between 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or credit. + * A customer's usage needs to meet the condition of at least one of the specifiers to + * contribute to a commit's or credit's drawdown. This field cannot be used together with + * `applicable_product_ids` or `applicable_product_tags`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") + + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") + + /** + * A temporary ID that can be used to reference the recurring commit for commit specific + * overrides. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount + + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration + + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency + + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = subscriptionConfig + + /** + * Returns the raw JSON value of [temporaryId]. + * + * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temporary_id") + @ExcludeMissing + fun _temporaryId(): JsonField = temporaryId + + @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 [RecurringCredit]. + * + * The following fields are required: + * ```java + * .accessAmount() + * .commitDuration() + * .priority() + * .productId() + * .startingAtOffset() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecurringCredit]. */ + class Builder internal constructor() { + + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var productId: JsonField? = null + private var startingAtOffset: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = JsonMissing.of() + private var temporaryId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recurringCredit: RecurringCredit) = apply { + accessAmount = recurringCredit.accessAmount + commitDuration = recurringCredit.commitDuration + priority = recurringCredit.priority + productId = recurringCredit.productId + startingAtOffset = recurringCredit.startingAtOffset + applicableProductIds = + recurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + recurringCredit.applicableProductTags.map { it.toMutableList() } + description = recurringCredit.description + duration = recurringCredit.duration + name = recurringCredit.name + proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding + rateType = recurringCredit.rateType + recurrenceFrequency = recurringCredit.recurrenceFrequency + rolloverFraction = recurringCredit.rolloverFraction + specifiers = recurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = recurringCredit.subscriptionConfig + temporaryId = recurringCredit.temporaryId + additionalProperties = recurringCredit.additionalProperties.toMutableMap() + } + + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a + * period is determined by the recurrence_frequency. + */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) + + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } + + /** Will be passed down to the individual commits */ + fun priority(priority: Double) = priority(JsonField.of(priority)) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + fun productId(productId: String) = productId(JsonField.of(productId)) + + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } + + /** + * Offset relative to the contract start date that determines the start time for the + * first commit + */ + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) + + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset + } + + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + /** Will be passed down to the individual commits */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Offset relative to the recurring credit start that determines when the contract will + * stop creating recurring commits. optional + */ + fun duration(duration: Duration) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** displayed on invoices. will be passed through to the individual commits */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) + + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } + + /** Optional rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) + + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { + this.recurrenceFrequency = recurrenceFrequency + } + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be between + * 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + */ + fun specifiers(specifiers: List) = + specifiers(JsonField.of(specifiers)) + + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [SubscriptionConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionConfig(subscriptionConfig: JsonField) = apply { + this.subscriptionConfig = subscriptionConfig + } + + /** + * A temporary ID that can be used to reference the recurring commit for commit specific + * overrides. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessAmount() + * .commitDuration() + * .priority() + * .productId() + * .startingAtOffset() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringCredit = + RecurringCredit( + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("productId", productId), + checkRequired("startingAtOffset", startingAtOffset), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + duration, + name, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + temporaryId, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RecurringCredit = apply { + if (validated) { + return@apply + } + + accessAmount().validate() + commitDuration().validate() + priority() + productId() + startingAtOffset().validate() + applicableProductIds() + applicableProductTags() + description() + duration().ifPresent { it.validate() } + name() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + temporaryId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") + + /** + * This field is required unless a subscription is attached via `subscription_config`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @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 [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** + * This field is required unless a subscription is attached via + * `subscription_config`. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + creditTypeId() + unitPrice() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a period + * is determined by the recurrence_frequency. + */ + class CommitDuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val unit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): Double = value.getRequired("value") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @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 [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } + + value() + unit().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERIODS = of("PERIODS") + + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } + + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS + } + + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } + + /** + * Offset relative to the contract start date that determines the start time for the first + * commit + */ + class StartingAtOffset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unit: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(unit, value, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unit(): Unit = unit.getRequired("unit") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): Long = value.getRequired("value") + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [StartingAtOffset]. + * + * The following fields are required: + * ```java + * .unit() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StartingAtOffset]. */ + class Builder internal constructor() { + + private var unit: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(startingAtOffset: StartingAtOffset) = apply { + unit = startingAtOffset.unit + value = startingAtOffset.value + additionalProperties = startingAtOffset.additionalProperties.toMutableMap() + } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun value(value: Long) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } fun removeAdditionalProperty(key: String) = apply { @@ -17574,21 +19059,22 @@ private constructor( } /** - * Returns an immutable instance of [CommitDuration]. + * Returns an immutable instance of [StartingAtOffset]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .unit() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CommitDuration = - CommitDuration( + fun build(): StartingAtOffset = + StartingAtOffset( + checkRequired("unit", unit), checkRequired("value", value), - unit, additionalProperties.toMutableMap(), ) } @@ -17605,13 +19091,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): CommitDuration = apply { + fun validate(): StartingAtOffset = apply { if (validated) { return@apply } + unit().validate() value() - unit().ifPresent { it.validate() } validated = true } @@ -17631,8 +19117,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) class Unit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17649,14 +19135,23 @@ private constructor( companion object { - @JvmField val PERIODS = of("PERIODS") + @JvmField val DAYS = of("DAYS") + + @JvmField val WEEKS = of("WEEKS") + + @JvmField val MONTHS = of("MONTHS") + + @JvmField val YEARS = of("YEARS") @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) } /** An enum containing [Unit]'s known values. */ enum class Known { - PERIODS + DAYS, + WEEKS, + MONTHS, + YEARS, } /** @@ -17669,7 +19164,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PERIODS, + DAYS, + WEEKS, + MONTHS, + YEARS, /** * An enum member indicating that [Unit] was instantiated with an unknown value. */ @@ -17685,7 +19183,10 @@ private constructor( */ fun value(): Value = when (this) { - PERIODS -> Value.PERIODS + DAYS -> Value.DAYS + WEEKS -> Value.WEEKS + MONTHS -> Value.MONTHS + YEARS -> Value.YEARS else -> Value._UNKNOWN } @@ -17700,7 +19201,10 @@ private constructor( */ fun known(): Known = when (this) { - PERIODS -> Known.PERIODS + DAYS -> Known.DAYS + WEEKS -> Known.WEEKS + MONTHS -> Known.MONTHS + YEARS -> Known.YEARS else -> throw MetronomeInvalidDataException("Unknown Unit: $value") } @@ -17773,25 +19277,25 @@ private constructor( return true } - return other is CommitDuration && - value == other.value && + return other is StartingAtOffset && unit == other.unit && + value == other.value && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" } /** - * Offset relative to the contract start date that determines the start time for the first - * commit + * Offset relative to the recurring credit start that determines when the contract will stop + * creating recurring commits. optional */ - class StartingAtOffset + class Duration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unit: JsonField, @@ -17848,7 +19352,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [StartingAtOffset]. + * Returns a mutable builder for constructing an instance of [Duration]. * * The following fields are required: * ```java @@ -17859,7 +19363,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [StartingAtOffset]. */ + /** A builder for [Duration]. */ class Builder internal constructor() { private var unit: JsonField? = null @@ -17867,10 +19371,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(startingAtOffset: StartingAtOffset) = apply { - unit = startingAtOffset.unit - value = startingAtOffset.value - additionalProperties = startingAtOffset.additionalProperties.toMutableMap() + internal fun from(duration: Duration) = apply { + unit = duration.unit + value = duration.value + additionalProperties = duration.additionalProperties.toMutableMap() } fun unit(unit: Unit) = unit(JsonField.of(unit)) @@ -17918,7 +19422,7 @@ private constructor( } /** - * Returns an immutable instance of [StartingAtOffset]. + * Returns an immutable instance of [Duration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -17930,8 +19434,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): StartingAtOffset = - StartingAtOffset( + fun build(): Duration = + Duration( checkRequired("unit", unit), checkRequired("value", value), additionalProperties.toMutableMap(), @@ -17950,7 +19454,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): StartingAtOffset = apply { + fun validate(): Duration = apply { if (validated) { return@apply } @@ -18123,78 +19627,215 @@ private constructor( return true } - return other is Unit && value == other.value + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Duration && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is StartingAtOffset && - unit == other.unit && - value == other.value && - additionalProperties == other.additionalProperties + return other is Proration && value == other.value } - private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Offset relative to the recurring credit start that determines when the contract will stop - * creating recurring commits. optional - */ - class Duration + /** Optional rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: JsonField, - private val value: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(unit, value, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun unit(): Unit = unit.getRequired("unit") + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): Long = value.getRequired("value") - - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [access]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -18211,52 +19852,33 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Duration]. - * - * The following fields are required: - * ```java - * .unit() - * .value() - * ``` + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Duration]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var unit: JsonField? = null - private var value: JsonField? = null + private var access: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(duration: Duration) = apply { - unit = duration.unit - value = duration.value - additionalProperties = duration.additionalProperties.toMutableMap() + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - fun unit(unit: Unit) = unit(JsonField.of(unit)) - - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - fun value(value: Long) = value(JsonField.of(value)) + fun access(access: Access) = access(JsonField.of(access)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.access] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun access(access: JsonField) = apply { this.access = access } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -18281,24 +19903,12 @@ private constructor( } /** - * Returns an immutable instance of [Duration]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .unit() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Duration = - Duration( - checkRequired("unit", unit), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -18313,13 +19923,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Duration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - unit().validate() - value() + access().ifPresent { it.validate() } validated = true } @@ -18338,112 +19947,181 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Returns this class instance's raw value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - @JvmField val DAYS = of("DAYS") + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - @JvmField val WEEKS = of("WEEKS") + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - @JvmField val MONTHS = of("MONTHS") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val YEARS = of("YEARS") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [Unit]'s known values. */ - enum class Known { - DAYS, - WEEKS, - MONTHS, - YEARS, - } + companion object { - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAYS, - WEEKS, - MONTHS, - YEARS, /** - * An enum member indicating that [Unit] was instantiated with an unknown value. + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAYS -> Value.DAYS - WEEKS -> Value.WEEKS - MONTHS -> Value.MONTHS - YEARS -> Value.YEARS - else -> Value._UNKNOWN + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAYS -> Known.DAYS - WEEKS -> Known.WEEKS - MONTHS -> Known.MONTHS - YEARS -> Known.YEARS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -18456,12 +20134,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Unit = apply { + fun validate(): Access = apply { if (validated) { return@apply } - known() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -18479,195 +20158,203 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Unit && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is Duration && - unit == other.unit && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val HALF_UP = of("HALF_UP") - override fun toString() = - "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" - } + @JvmField val FLOOR = of("FLOOR") - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField val CEILING = of("CEILING") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - companion object { + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - @JvmField val NONE = of("NONE") + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmField val FIRST = of("FIRST") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - @JvmField val LAST = of("LAST") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + private var validated: Boolean = false - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + known() + validated = true + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var validated: Boolean = false + return other is RoundingMethod && value == other.value + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Proration = apply { - if (validated) { - return@apply + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** Whether the created commits will use the commit rate or list rate */ @@ -18841,6 +20528,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -18850,6 +20539,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -18868,6 +20558,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -18888,6 +20579,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -18906,6 +20598,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") } @@ -19602,6 +21295,7 @@ private constructor( duration == other.duration && name == other.name && proration == other.proration && + prorationRounding == other.prorationRounding && rateType == other.rateType && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && @@ -19624,6 +21318,7 @@ private constructor( duration, name, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -19637,7 +21332,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + "RecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" } class ScheduledCharge @@ -20729,308 +22424,612 @@ private constructor( return other is Unit && value == other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DateOffset && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unit, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DateOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduleItem && + dateOffset == other.dateOffset && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dateOffset, quantity, unitPrice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduleItem{dateOffset=$dateOffset, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Schedule && + scheduleItems == other.scheduleItems && + creditTypeId == other.creditTypeId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scheduleItems, creditTypeId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{scheduleItems=$scheduleItems, creditTypeId=$creditTypeId, additionalProperties=$additionalProperties}" + } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @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 [CustomFields]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CustomFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns 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 CustomFields && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduledCharge && + productId == other.productId && + schedule == other.schedule && + customFields == other.customFields && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(productId, schedule, customFields, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, additionalProperties=$additionalProperties}" + } + + /** + * Determines which scheduled and commit charges to consolidate onto the Contract's usage + * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for + * consolidation to occur. This field cannot be modified after a Contract has been created. If + * this field is omitted, charges will appear on a separate invoice from usage charges. + */ + class ScheduledChargesOnUsageInvoices + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { - override fun toString() = value.toString() - } + @JvmField val ALL = of("ALL") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) + } - return other is DateOffset && - unit == other.unit && - value == other.value && - additionalProperties == other.additionalProperties - } + /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ + enum class Known { + ALL + } - private val hashCode: Int by lazy { - Objects.hash(unit, value, additionalProperties) - } + /** + * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + /** + * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - override fun hashCode(): Int = hashCode + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + else -> Value._UNKNOWN + } - override fun toString() = - "DateOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + else -> + throw MetronomeInvalidDataException( + "Unknown ScheduledChargesOnUsageInvoices: $value" + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - return other is ScheduleItem && - dateOffset == other.dateOffset && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } + private var validated: Boolean = false - private val hashCode: Int by lazy { - Objects.hash(dateOffset, quantity, unitPrice, additionalProperties) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScheduledChargesOnUsageInvoices = apply { + if (validated) { + return@apply + } - override fun hashCode(): Int = hashCode + known() + validated = true + } - override fun toString() = - "ScheduleItem{dateOffset=$dateOffset, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - return other is Schedule && - scheduleItems == other.scheduleItems && - creditTypeId == other.creditTypeId && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash(scheduleItems, creditTypeId, additionalProperties) - } + return other is ScheduledChargesOnUsageInvoices && value == other.value + } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Schedule{scheduleItems=$scheduleItems, creditTypeId=$creditTypeId, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() + } + + class SpendTracker + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val alias: JsonField, + private val applicableSpendSpecifiers: JsonField>, + private val creditTypeId: JsonField, + private val resetFrequency: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields @JsonCreator private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("applicable_spend_specifiers") @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) + applicableSpendSpecifiers: JsonField> = JsonMissing.of(), + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("reset_frequency") + @ExcludeMissing + resetFrequency: JsonField = JsonMissing.of(), + ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) - companion object { + /** + * Human-readable identifier, unique per contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun alias(): String = alias.getRequired("alias") - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun applicableSpendSpecifiers(): List = + applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [applicableSpendSpecifiers]. + * + * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + fun _applicableSpendSpecifiers(): JsonField> = + applicableSpendSpecifiers - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [resetFrequency]. + * + * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reset_frequency") + @ExcludeMissing + fun _resetFrequency(): JsonField = resetFrequency - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns a mutable builder for constructing an instance of [SpendTracker]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + @JvmStatic fun builder() = Builder() + } - validated = true + /** A builder for [SpendTracker]. */ + class Builder internal constructor() { + + private var alias: JsonField? = null + private var applicableSpendSpecifiers: + JsonField>? = + null + private var creditTypeId: JsonField? = null + private var resetFrequency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spendTracker: SpendTracker) = apply { + alias = spendTracker.alias + applicableSpendSpecifiers = + spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } + creditTypeId = spendTracker.creditTypeId + resetFrequency = spendTracker.resetFrequency + additionalProperties = spendTracker.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Human-readable identifier, unique per contract. */ + fun alias(alias: String) = alias(JsonField.of(alias)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.alias] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + fun alias(alias: JsonField) = apply { this.alias = alias } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: List + ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) - return other is CustomFields && additionalProperties == other.additionalProperties + /** + * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: JsonField> + ) = apply { + this.applicableSpendSpecifiers = + applicableSpendSpecifiers.map { it.toMutableList() } } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode + /** + * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = + apply { + applicableSpendSpecifiers = + (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableSpendSpecifiers", it) + .add(applicableSpendSpecifier) + } + } - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" - } + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId } - return other is ScheduledCharge && - productId == other.productId && - schedule == other.schedule && - customFields == other.customFields && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(productId, schedule, customFields, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, additionalProperties=$additionalProperties}" - } - - /** - * Determines which scheduled and commit charges to consolidate onto the Contract's usage - * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for - * consolidation to occur. This field cannot be modified after a Contract has been created. If - * this field is omitted, charges will appear on a separate invoice from usage charges. - */ - class ScheduledChargesOnUsageInvoices - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ALL = of("ALL") - - @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) - } - - /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ - enum class Known { - ALL - } + fun resetFrequency(resetFrequency: ResetFrequency) = + resetFrequency(JsonField.of(resetFrequency)) - /** - * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ALL, /** - * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated - * with an unknown value. + * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - else -> - throw MetronomeInvalidDataException( - "Unknown ScheduledChargesOnUsageInvoices: $value" - ) + fun resetFrequency(resetFrequency: JsonField) = apply { + this.resetFrequency = resetFrequency } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SpendTracker]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendTracker = + SpendTracker( + checkRequired("alias", alias), + checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { + it.toImmutable() + }, + checkRequired("creditTypeId", creditTypeId), + checkRequired("resetFrequency", resetFrequency), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -21042,12 +23041,15 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): ScheduledChargesOnUsageInvoices = apply { + fun validate(): SpendTracker = apply { if (validated) { return@apply } - known() + alias() + applicableSpendSpecifiers().forEach { it.validate() } + creditTypeId() + resetFrequency().validate() validated = true } @@ -21065,534 +23067,803 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (alias.asKnown().isPresent) 1 else 0) + + (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class ApplicableSpendSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sources: JsonField>, + private val spendType: JsonField, + private val discounted: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is ScheduledChargesOnUsageInvoices && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("sources") + @ExcludeMissing + sources: JsonField> = JsonMissing.of(), + @JsonProperty("spend_type") + @ExcludeMissing + spendType: JsonField = JsonMissing.of(), + @JsonProperty("discounted") + @ExcludeMissing + discounted: JsonField = JsonMissing.of(), + ) : this(sources, spendType, discounted, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun sources(): List = sources.getRequired("sources") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun spendType(): SpendType = spendType.getRequired("spend_type") - class SpendTracker - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val alias: JsonField, - private val applicableSpendSpecifiers: JsonField>, - private val creditTypeId: JsonField, - private val resetFrequency: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Filter by whether the spend was discounted. Defaults to ANY if omitted. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun discounted(): Optional = discounted.getOptional("discounted") - @JsonCreator - private constructor( - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("applicable_spend_specifiers") + /** + * Returns the raw JSON value of [sources]. + * + * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sources") @ExcludeMissing - applicableSpendSpecifiers: JsonField> = JsonMissing.of(), - @JsonProperty("credit_type_id") + fun _sources(): JsonField> = sources + + /** + * Returns the raw JSON value of [spendType]. + * + * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spend_type") @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("reset_frequency") + fun _spendType(): JsonField = spendType + + /** + * Returns the raw JSON value of [discounted]. + * + * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discounted") @ExcludeMissing - resetFrequency: JsonField = JsonMissing.of(), - ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + fun _discounted(): JsonField = discounted - /** - * Human-readable identifier, unique per contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun alias(): String = alias.getRequired("alias") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun applicableSpendSpecifiers(): List = - applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ApplicableSpendSpecifier]. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplicableSpendSpecifier]. */ + class Builder internal constructor() { + + private var sources: JsonField>? = null + private var spendType: JsonField? = null + private var discounted: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { + sources = applicableSpendSpecifier.sources.map { it.toMutableList() } + spendType = applicableSpendSpecifier.spendType + discounted = applicableSpendSpecifier.discounted + additionalProperties = + applicableSpendSpecifier.additionalProperties.toMutableMap() + } + + fun sources(sources: List) = sources(JsonField.of(sources)) + + /** + * Sets [Builder.sources] to an arbitrary JSON value. + * + * You should usually call [Builder.sources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sources(sources: JsonField>) = apply { + this.sources = sources.map { it.toMutableList() } + } + + /** + * Adds a single [Source] to [sources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: Source) = apply { + sources = + (sources ?: JsonField.of(mutableListOf())).also { + checkKnown("sources", it).add(source) + } + } + + fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + + /** + * Sets [Builder.spendType] to an arbitrary JSON value. + * + * You should usually call [Builder.spendType] with a well-typed [SpendType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun spendType(spendType: JsonField) = apply { + this.spendType = spendType + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + /** + * Sets [Builder.discounted] to an arbitrary JSON value. + * + * You should usually call [Builder.discounted] with a well-typed [Discounted] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun discounted(discounted: JsonField) = apply { + this.discounted = discounted + } - /** - * Returns the raw JSON value of [applicableSpendSpecifiers]. - * - * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - fun _applicableSpendSpecifiers(): JsonField> = - applicableSpendSpecifiers + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [resetFrequency]. - * - * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reset_frequency") - @ExcludeMissing - fun _resetFrequency(): JsonField = resetFrequency + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [ApplicableSpendSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplicableSpendSpecifier = + ApplicableSpendSpecifier( + checkRequired("sources", sources).map { it.toImmutable() }, + checkRequired("spendType", spendType), + discounted, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [SpendTracker]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SpendTracker]. */ - class Builder internal constructor() { - - private var alias: JsonField? = null - private var applicableSpendSpecifiers: - JsonField>? = - null - private var creditTypeId: JsonField? = null - private var resetFrequency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): ApplicableSpendSpecifier = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(spendTracker: SpendTracker) = apply { - alias = spendTracker.alias - applicableSpendSpecifiers = - spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } - creditTypeId = spendTracker.creditTypeId - resetFrequency = spendTracker.resetFrequency - additionalProperties = spendTracker.additionalProperties.toMutableMap() + sources().forEach { it.validate() } + spendType().validate() + discounted().ifPresent { it.validate() } + validated = true } - /** Human-readable identifier, unique per contract. */ - fun alias(alias: String) = alias(JsonField.of(alias)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.alias] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun alias(alias: JsonField) = apply { this.alias = alias } + @JvmSynthetic + internal fun validity(): Int = + (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (spendType.asKnown().getOrNull()?.validity() ?: 0) + + (discounted.asKnown().getOrNull()?.validity() ?: 0) + + class Source @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + + @JvmField val MANUAL = of("MANUAL") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + THRESHOLD_RECHARGE, + MANUAL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_RECHARGE, + MANUAL, + /** + * An enum member indicating that [Source] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE + MANUAL -> Known.MANUAL + else -> throw MetronomeInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: List - ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + private var validated: Boolean = false - /** - * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: JsonField> - ) = apply { - this.applicableSpendSpecifiers = - applicableSpendSpecifiers.map { it.toMutableList() } - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Source = apply { + if (validated) { + return@apply + } - /** - * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = - apply { - applicableSpendSpecifiers = - (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableSpendSpecifiers", it) - .add(applicableSpendSpecifier) - } + known() + validated = true } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun resetFrequency(resetFrequency: ResetFrequency) = - resetFrequency(JsonField.of(resetFrequency)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Sets [Builder.resetFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun resetFrequency(resetFrequency: JsonField) = apply { - this.resetFrequency = resetFrequency - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + return other is Source && value == other.value + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode() = value.hashCode() - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + override fun toString() = value.toString() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + class SpendType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Returns an immutable instance of [SpendTracker]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SpendTracker = - SpendTracker( - checkRequired("alias", alias), - checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { - it.toImmutable() - }, - checkRequired("creditTypeId", creditTypeId), - checkRequired("resetFrequency", resetFrequency), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): SpendTracker = apply { - if (validated) { - return@apply - } + @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") - alias() - applicableSpendSpecifiers().forEach { it.validate() } - creditTypeId() - resetFrequency().validate() - validated = true - } + @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** An enum containing [SpendType]'s known values. */ + enum class Known { + COMMIT_PURCHASE + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (alias.asKnown().isPresent) 1 else 0) + - (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + /** + * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SpendType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_PURCHASE, + /** + * An enum member indicating that [SpendType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - class ApplicableSpendSpecifier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sources: JsonField>, - private val spendType: JsonField, - private val discounted: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_PURCHASE -> Value.COMMIT_PURCHASE + else -> Value._UNKNOWN + } - @JsonCreator - private constructor( - @JsonProperty("sources") - @ExcludeMissing - sources: JsonField> = JsonMissing.of(), - @JsonProperty("spend_type") - @ExcludeMissing - spendType: JsonField = JsonMissing.of(), - @JsonProperty("discounted") - @ExcludeMissing - discounted: JsonField = JsonMissing.of(), - ) : this(sources, spendType, discounted, mutableMapOf()) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_PURCHASE -> Known.COMMIT_PURCHASE + else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun sources(): List = sources.getRequired("sources") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun spendType(): SpendType = spendType.getRequired("spend_type") + private var validated: Boolean = false - /** - * Filter by whether the spend was discounted. Defaults to ANY if omitted. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun discounted(): Optional = discounted.getOptional("discounted") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SpendType = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [sources]. - * - * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sources") - @ExcludeMissing - fun _sources(): JsonField> = sources + known() + validated = true + } - /** - * Returns the raw JSON value of [spendType]. - * - * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("spend_type") - @ExcludeMissing - fun _spendType(): JsonField = spendType + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [discounted]. - * - * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discounted") - @ExcludeMissing - fun _discounted(): JsonField = discounted + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is SpendType && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } + + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + class Discounted + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of - * [ApplicableSpendSpecifier]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [ApplicableSpendSpecifier]. */ - class Builder internal constructor() { + companion object { - private var sources: JsonField>? = null - private var spendType: JsonField? = null - private var discounted: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ANY = of("ANY") - @JvmSynthetic - internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { - sources = applicableSpendSpecifier.sources.map { it.toMutableList() } - spendType = applicableSpendSpecifier.spendType - discounted = applicableSpendSpecifier.discounted - additionalProperties = - applicableSpendSpecifier.additionalProperties.toMutableMap() + @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + + @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + + @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) } - fun sources(sources: List) = sources(JsonField.of(sources)) + /** An enum containing [Discounted]'s known values. */ + enum class Known { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + } /** - * Sets [Builder.sources] to an arbitrary JSON value. + * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.sources] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An instance of [Discounted] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun sources(sources: JsonField>) = apply { - this.sources = sources.map { it.toMutableList() } + enum class Value { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + /** + * An enum member indicating that [Discounted] was instantiated with an unknown + * value. + */ + _UNKNOWN, } /** - * Adds a single [Source] to [sources]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun addSource(source: Source) = apply { - sources = - (sources ?: JsonField.of(mutableListOf())).also { - checkKnown("sources", it).add(source) - } - } + fun value(): Value = + when (this) { + ANY -> Value.ANY + DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY + else -> Value._UNKNOWN + } - fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANY -> Known.ANY + DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY + else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") + } /** - * Sets [Builder.spendType] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.spendType] with a well-typed [SpendType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun spendType(spendType: JsonField) = apply { - this.spendType = spendType + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Discounted = apply { + if (validated) { + return@apply + } + + known() + validated = true } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.discounted] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.discounted] with a well-typed [Discounted] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Used for best match union deserialization. */ - fun discounted(discounted: JsonField) = apply { - this.discounted = discounted - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + return other is Discounted && value == other.value } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun hashCode() = value.hashCode() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun toString() = value.toString() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + return other is ApplicableSpendSpecifier && + sources == other.sources && + spendType == other.spendType && + discounted == other.discounted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sources, spendType, discounted, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + } + + class ResetFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + + @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + } + + /** An enum containing [ResetFrequency]'s known values. */ + enum class Known { + BILLING_PERIOD + } + + /** + * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILLING_PERIOD, /** - * Returns an immutable instance of [ApplicableSpendSpecifier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [ResetFrequency] was instantiated with an unknown + * value. */ - fun build(): ApplicableSpendSpecifier = - ApplicableSpendSpecifier( - checkRequired("sources", sources).map { it.toImmutable() }, - checkRequired("spendType", spendType), - discounted, - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILLING_PERIOD -> Value.BILLING_PERIOD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BILLING_PERIOD -> Known.BILLING_PERIOD + else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -21605,14 +23876,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ApplicableSpendSpecifier = apply { + fun validate(): ResetFrequency = apply { if (validated) { return@apply } - sources().forEach { it.validate() } - spendType().validate() - discounted().ifPresent { it.validate() } + known() validated = true } @@ -21630,460 +23899,725 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (spendType.asKnown().getOrNull()?.validity() ?: 0) + - (discounted.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResetFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendTracker && + alias == other.alias && + applicableSpendSpecifiers == other.applicableSpendSpecifiers && + creditTypeId == other.creditTypeId && + resetFrequency == other.resetFrequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + alias, + applicableSpendSpecifiers, + creditTypeId, + resetFrequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" + } + + class Subscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val subscriptionRate: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val initialQuantity: JsonField, + private val name: JsonField, + private val quantityManagementMode: JsonField, + private val seatConfig: JsonField, + private val startingAtOffset: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("initial_quantity") + @ExcludeMissing + initialQuantity: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + @JsonProperty("temporary_id") + @ExcludeMissing + temporaryId: JsonField = JsonMissing.of(), + ) : this( + collectionSchedule, + proration, + subscriptionRate, + billingCycleConfig, + customFields, + description, + duration, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + temporaryId, + mutableMapOf(), + ) - class Source @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun proration(): Proration = proration.getRequired("proration") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") - @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") - @JvmField val MANUAL = of("MANUAL") + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** An enum containing [Source]'s known values. */ - enum class Known { - THRESHOLD_RECHARGE, - MANUAL, - } + /** + * Lifetime of the subscription from its start. If not provided, subscription inherits + * contract end date. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") - /** - * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_RECHARGE, - MANUAL, - /** - * An enum member indicating that [Source] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE - MANUAL -> Value.MANUAL - else -> Value._UNKNOWN - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE - MANUAL -> Known.MANUAL - else -> throw MetronomeInvalidDataException("Unknown Source: $value") - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantityManagementMode(): Optional = + quantityManagementMode.getOptional("quantity_management_mode") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - private var validated: Boolean = false + /** + * Relative date from contract start date corresponding to the inclusive start time for the + * subscription. If not provided, defaults to contract start date + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAtOffset(): Optional = + startingAtOffset.getOptional("starting_at_offset") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Source = apply { - if (validated) { - return@apply - } + /** + * A temporary ID used to reference the subscription in recurring commit/credit subscription + * configs created within the same payload. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") - known() - validated = true - } + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - return other is Source && value == other.value - } + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - class SpendType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [initialQuantity]. + * + * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_quantity") + @ExcludeMissing + fun _initialQuantity(): JsonField = initialQuantity - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - companion object { + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = quantityManagementMode - @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset - /** An enum containing [SpendType]'s known values. */ - enum class Known { - COMMIT_PURCHASE - } + /** + * Returns the raw JSON value of [temporaryId]. + * + * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temporary_id") + @ExcludeMissing + fun _temporaryId(): JsonField = temporaryId - /** - * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [SpendType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_PURCHASE, - /** - * An enum member indicating that [SpendType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_PURCHASE -> Value.COMMIT_PURCHASE - else -> Value._UNKNOWN - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_PURCHASE -> Known.COMMIT_PURCHASE - else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") - } + fun toBuilder() = Builder().from(this) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SpendType = apply { - if (validated) { - return@apply - } + /** A builder for [Subscription]. */ + class Builder internal constructor() { - known() - validated = true - } + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var subscriptionRate: JsonField? = null + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var initialQuantity: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quantityManagementMode: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var startingAtOffset: JsonField = JsonMissing.of() + private var temporaryId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + collectionSchedule = subscription.collectionSchedule + proration = subscription.proration + subscriptionRate = subscription.subscriptionRate + billingCycleConfig = subscription.billingCycleConfig + customFields = subscription.customFields + description = subscription.description + duration = subscription.duration + initialQuantity = subscription.initialQuantity + name = subscription.name + quantityManagementMode = subscription.quantityManagementMode + seatConfig = subscription.seatConfig + startingAtOffset = subscription.startingAtOffset + temporaryId = subscription.temporaryId + additionalProperties = subscription.additionalProperties.toMutableMap() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) + + /** + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun proration(proration: Proration) = proration(JsonField.of(proration)) - return other is SpendType && value == other.value - } + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } - override fun hashCode() = value.hashCode() + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - override fun toString() = value.toString() + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - class Discounted - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) - companion object { + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } - @JvmField val ANY = of("ANY") + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) - @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } - @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + fun description(description: String) = description(JsonField.of(description)) - @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** An enum containing [Discounted]'s known values. */ - enum class Known { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - } + /** + * Lifetime of the subscription from its start. If not provided, subscription inherits + * contract end date. + */ + fun duration(duration: Duration) = duration(JsonField.of(duration)) - /** - * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Discounted] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - /** - * An enum member indicating that [Discounted] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANY -> Value.ANY - DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY - else -> Value._UNKNOWN - } + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + */ + fun initialQuantity(initialQuantity: Double) = + initialQuantity(JsonField.of(initialQuantity)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANY -> Known.ANY - DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY - else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") - } + /** + * Sets [Builder.initialQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.initialQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun initialQuantity(initialQuantity: JsonField) = apply { + this.initialQuantity = initialQuantity + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun name(name: String) = name(JsonField.of(name)) - private var validated: Boolean = false + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Discounted = apply { - if (validated) { - return@apply - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per + * seat. `seat_config` must be provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) - known() - validated = true + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode(quantityManagementMode: JsonField) = + apply { + this.quantityManagementMode = quantityManagementMode } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } + + /** + * Relative date from contract start date corresponding to the inclusive start time for + * the subscription. If not provided, defaults to contract start date + */ + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset + } - return other is Discounted && value == other.value - } + /** + * A temporary ID used to reference the subscription in recurring commit/credit + * subscription configs created within the same payload. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId + } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is ApplicableSpendSpecifier && - sources == other.sources && - spendType == other.spendType && - discounted == other.discounted && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(sources, spendType, discounted, additionalProperties) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode + /** + * Returns an immutable instance of [Subscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("subscriptionRate", subscriptionRate), + billingCycleConfig, + customFields, + description, + duration, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + temporaryId, + additionalProperties.toMutableMap(), + ) + } - override fun toString() = - "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + collectionSchedule().validate() + proration().validate() + subscriptionRate().validate() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + duration().ifPresent { it.validate() } + initialQuantity() + name() + quantityManagementMode().ifPresent { it.validate() } + seatConfig().ifPresent { it.validate() } + startingAtOffset().ifPresent { it.validate() } + temporaryId() + validated = true } - class ResetFrequency + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (initialQuantity.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) + + class CollectionSchedule @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22099,30 +24633,36 @@ private constructor( companion object { - @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + @JvmField val ADVANCE = of("ADVANCE") - @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - /** An enum containing [ResetFrequency]'s known values. */ + /** An enum containing [CollectionSchedule]'s known values. */ enum class Known { - BILLING_PERIOD + ADVANCE, + ARREARS, } /** - * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILLING_PERIOD, + ADVANCE, + ARREARS, /** - * An enum member indicating that [ResetFrequency] was instantiated with an unknown - * value. + * An enum member indicating that [CollectionSchedule] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -22136,7 +24676,8 @@ private constructor( */ fun value(): Value = when (this) { - BILLING_PERIOD -> Value.BILLING_PERIOD + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS else -> Value._UNKNOWN } @@ -22151,8 +24692,10 @@ private constructor( */ fun known(): Known = when (this) { - BILLING_PERIOD -> Known.BILLING_PERIOD - else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") } /** @@ -22181,7 +24724,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ResetFrequency = apply { + fun validate(): CollectionSchedule = apply { if (validated) { return@apply } @@ -22199,890 +24742,882 @@ private constructor( } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CollectionSchedule && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Proration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("invoice_behavior") + @ExcludeMissing + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) + + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoiceBehavior(): Optional = + invoiceBehavior.getOptional("invoice_behavior") + + /** + * Indicates if the partial period will be prorated or charged a full amount. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isProrated(): Optional = isProrated.getOptional("is_prorated") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + + /** + * Returns the raw JSON value of [invoiceBehavior]. + * + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_behavior") + @ExcludeMissing + fun _invoiceBehavior(): JsonField = invoiceBehavior + + /** + * Returns the raw JSON value of [isProrated]. * - * Used for best match union deserialization. + * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding - return other is ResetFrequency && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = value.toString() - } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is SpendTracker && - alias == other.alias && - applicableSpendSpecifiers == other.applicableSpendSpecifiers && - creditTypeId == other.creditTypeId && - resetFrequency == other.resetFrequency && - additionalProperties == other.additionalProperties - } + /** Returns a mutable builder for constructing an instance of [Proration]. */ + @JvmStatic fun builder() = Builder() + } - private val hashCode: Int by lazy { - Objects.hash( - alias, - applicableSpendSpecifiers, - creditTypeId, - resetFrequency, - additionalProperties, - ) - } + /** A builder for [Proration]. */ + class Builder internal constructor() { - override fun hashCode(): Int = hashCode + private var invoiceBehavior: JsonField = JsonMissing.of() + private var isProrated: JsonField = JsonMissing.of() + private var rounding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" - } + @JvmSynthetic + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() + } - class Subscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val subscriptionRate: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val duration: JsonField, - private val initialQuantity: JsonField, - private val name: JsonField, - private val quantityManagementMode: JsonField, - private val seatConfig: JsonField, - private val startingAtOffset: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will + * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: + * The quantity increase will be billed for in-arrears at the end of the period. + */ + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) - @JsonCreator - private constructor( - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("initial_quantity") - @ExcludeMissing - initialQuantity: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") - @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - @JsonProperty("temporary_id") - @ExcludeMissing - temporaryId: JsonField = JsonMissing.of(), - ) : this( - collectionSchedule, - proration, - subscriptionRate, - customFields, - description, - duration, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - temporaryId, - mutableMapOf(), - ) + /** + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + /** Indicates if the partial period will be prorated or charged a full amount. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun proration(): Proration = proration.getRequired("proration") + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Lifetime of the subscription from its start. If not provided, subscription inherits - * contract end date. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantityManagementMode(): Optional = - quantityManagementMode.getOptional("quantity_management_mode") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + /** + * Returns an immutable instance of [Proration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Proration = + Proration( + invoiceBehavior, + isProrated, + rounding, + additionalProperties.toMutableMap(), + ) + } - /** - * Relative date from contract start date corresponding to the inclusive start time for the - * subscription. If not provided, defaults to contract start date - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startingAtOffset(): Optional = - startingAtOffset.getOptional("starting_at_offset") + private var validated: Boolean = false - /** - * A temporary ID used to reference the subscription in recurring commit/credit subscription - * configs created within the same payload. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + invoiceBehavior().ifPresent { it.validate() } + isProrated() + rounding().ifPresent { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + */ + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + companion object { - /** - * Returns the raw JSON value of [initialQuantity]. - * - * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("initial_quantity") - @ExcludeMissing - fun _initialQuantity(): JsonField = initialQuantity + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = quantityManagementMode + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [temporaryId]. - * - * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("temporary_id") - @ExcludeMissing - fun _temporaryId(): JsonField = temporaryId + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + known() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns a mutable builder for constructing an instance of [Subscription]. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** A builder for [Subscription]. */ - class Builder internal constructor() { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var subscriptionRate: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var initialQuantity: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantityManagementMode: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var startingAtOffset: JsonField = JsonMissing.of() - private var temporaryId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + return other is InvoiceBehavior && value == other.value + } - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - collectionSchedule = subscription.collectionSchedule - proration = subscription.proration - subscriptionRate = subscription.subscriptionRate - customFields = subscription.customFields - description = subscription.description - duration = subscription.duration - initialQuantity = subscription.initialQuantity - name = subscription.name - quantityManagementMode = subscription.quantityManagementMode - seatConfig = subscription.seatConfig - startingAtOffset = subscription.startingAtOffset - temporaryId = subscription.temporaryId - additionalProperties = subscription.additionalProperties.toMutableMap() + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - fun proration(proration: Proration) = proration(JsonField.of(proration)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun description(description: String) = description(JsonField.of(description)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + companion object { - /** - * Lifetime of the subscription from its start. If not provided, subscription inherits - * contract end date. - */ - fun duration(duration: Duration) = duration(JsonField.of(duration)) + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** A builder for [Rounding]. */ + class Builder internal constructor() { - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - */ - fun initialQuantity(initialQuantity: Double) = - initialQuantity(JsonField.of(initialQuantity)) + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.initialQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.initialQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun initialQuantity(initialQuantity: JsonField) = apply { - this.initialQuantity = initialQuantity - } + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - fun name(name: String) = name(JsonField.of(name)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per - * seat. `seat_config` must be provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode(quantityManagementMode: JsonField) = - apply { - this.quantityManagementMode = quantityManagementMode - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Relative date from contract start date corresponding to the inclusive start time for - * the subscription. If not provided, defaults to contract start date - */ - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset - } + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - /** - * A temporary ID used to reference the subscription in recurring commit/credit - * subscription configs created within the same payload. - */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + private var validated: Boolean = false - /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. - * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns an immutable instance of [Subscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Subscription = - Subscription( - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("subscriptionRate", subscriptionRate), - customFields, - description, - duration, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - temporaryId, - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + @JvmField val HALF_UP = of("HALF_UP") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Subscription = apply { - if (validated) { - return@apply - } + @JvmField val FLOOR = of("FLOOR") - collectionSchedule().validate() - proration().validate() - subscriptionRate().validate() - customFields().ifPresent { it.validate() } - description() - duration().ifPresent { it.validate() } - initialQuantity() - name() - quantityManagementMode().ifPresent { it.validate() } - seatConfig().ifPresent { it.validate() } - startingAtOffset().ifPresent { it.validate() } - temporaryId() - validated = true - } + @JvmField val CEILING = of("CEILING") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (initialQuantity.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - class CollectionSchedule - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - companion object { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmField val ADVANCE = of("ADVANCE") + private var validated: Boolean = false - @JvmField val ARREARS = of("ARREARS") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } + known() + validated = true + } - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") - } + return other is RoundingMethod && value == other.value + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CollectionSchedule && value == other.value + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" } - class Proration + class SubscriptionRate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val billingFrequency: JsonField, + private val productId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product_id") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + productId: JsonField = JsonMissing.of(), + ) : this(billingFrequency, productId, mutableMapOf()) /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun invoiceBehavior(): Optional = - invoiceBehavior.getOptional("invoice_behavior") + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") /** - * Indicates if the partial period will be prorated or charged a full amount. + * Must be subscription type product * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun isProrated(): Optional = isProrated.getOptional("is_prorated") + fun productId(): String = productId.getRequired("product_id") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [billingFrequency]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _billingFrequency(): JsonField = billingFrequency /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [productId]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("is_prorated") + @JsonProperty("product_id") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _productId(): JsonField = productId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23098,57 +25633,61 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Proration]. */ + /** + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [SubscriptionRate]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField = JsonMissing.of() - private var isProrated: JsonField = JsonMissing.of() + private var billingFrequency: JsonField? = null + private var productId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() - } - - /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will - * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: - * The quantity increase will be billed for in-arrears at the end of the period. + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + productId = subscriptionRate.productId + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + } + + /** + * Frequency to bill subscription with. Together with product_id, must match + * existing rate on the rate card. */ - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the field + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency } - /** Indicates if the partial period will be prorated or charged a full amount. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** Must be subscription type product */ + fun productId(productId: String) = productId(JsonField.of(productId)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.productId] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * You should usually call [Builder.productId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + fun productId(productId: JsonField) = apply { this.productId = productId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -23173,12 +25712,24 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [SubscriptionRate]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration(invoiceBehavior, isProrated, additionalProperties.toMutableMap()) + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("productId", productId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -23193,13 +25744,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - invoiceBehavior().ifPresent { it.validate() } - isProrated() + billingFrequency().validate() + productId() validated = true } @@ -23219,16 +25770,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (productId.asKnown().isPresent) 1 else 0) /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. */ - class InvoiceBehavior + class BillingFrequency @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23244,24 +25793,30 @@ private constructor( companion object { - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + @JvmField val MONTHLY = of("MONTHLY") - @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + @JvmField val QUARTERLY = of("QUARTERLY") - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) } - /** An enum containing [InvoiceBehavior]'s known values. */ + /** An enum containing [BillingFrequency]'s known values. */ enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, } /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * An instance of [BillingFrequency] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -23269,10 +25824,12 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an + * An enum member indicating that [BillingFrequency] was instantiated with an * unknown value. */ _UNKNOWN, @@ -23287,8 +25844,10 @@ private constructor( */ fun value(): Value = when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -23303,10 +25862,12 @@ private constructor( */ fun known(): Known = when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY else -> - throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") } /** @@ -23335,7 +25896,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): InvoiceBehavior = apply { + fun validate(): BillingFrequency = apply { if (validated) { return@apply } @@ -23365,7 +25926,7 @@ private constructor( return true } - return other is InvoiceBehavior && value == other.value + return other is BillingFrequency && value == other.value } override fun hashCode() = value.hashCode() @@ -23378,79 +25939,55 @@ private constructor( return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + productId == other.productId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(billingFrequency, productId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" } - class SubscriptionRate + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val billingFrequency: JsonField, - private val productId: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product_id") + @JsonProperty("invoice_placement") @ExcludeMissing - productId: JsonField = JsonMissing.of(), - ) : this(billingFrequency, productId, mutableMapOf()) - - /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + invoicePlacement: JsonField = JsonMissing.of() + ) : this(invoicePlacement, mutableMapOf()) /** - * Must be subscription type product + * Controls whether subscriptions consolidate onto usage invoices. Defaults to + * ON_USAGE_INVOICE if omitted. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun productId(): String = productId.getRequired("product_id") + fun invoicePlacement(): Optional = + invoicePlacement.getOptional("invoice_placement") /** - * Returns the raw JSON value of [billingFrequency]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("billing_frequency") - @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency - - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") + @JsonProperty("invoice_placement") @ExcludeMissing - fun _productId(): JsonField = productId + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23467,61 +26004,41 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` + * Returns a mutable builder for constructing an instance of [BillingCycleConfig]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionRate]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var billingFrequency: JsonField? = null - private var productId: JsonField? = null + private var invoicePlacement: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - productId = subscriptionRate.productId - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() } /** - * Frequency to bill subscription with. Together with product_id, must match - * existing rate on the rate card. + * Controls whether subscriptions consolidate onto usage invoices. Defaults to + * ON_USAGE_INVOICE if omitted. */ - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the field + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement } - /** Must be subscription type product */ - fun productId(productId: String) = productId(JsonField.of(productId)) - - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23545,24 +26062,12 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionRate]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("productId", productId), - additionalProperties.toMutableMap(), - ) + fun build(): BillingCycleConfig = + BillingCycleConfig(invoicePlacement, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -23577,13 +26082,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): SubscriptionRate = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - billingFrequency().validate() - productId() + invoicePlacement().ifPresent { it.validate() } validated = true } @@ -23602,15 +26106,13 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (productId.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. + * Controls whether subscriptions consolidate onto usage invoices. Defaults to + * ON_USAGE_INVOICE if omitted. */ - class BillingFrequency + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23626,30 +26128,24 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [BillingFrequency]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [BillingFrequency] can contain an unknown value in a couple of + * An instance of [InvoicePlacement] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -23657,12 +26153,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [BillingFrequency] was instantiated with an + * An enum member indicating that [InvoicePlacement] was instantiated with an * unknown value. */ _UNKNOWN, @@ -23677,10 +26171,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -23695,12 +26187,10 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE else -> - throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") } /** @@ -23729,7 +26219,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): BillingFrequency = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -23759,7 +26249,7 @@ private constructor( return true } - return other is BillingFrequency && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -23772,20 +26262,19 @@ private constructor( return true } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - productId == other.productId && + return other is BillingCycleConfig && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(billingFrequency, productId, additionalProperties) + Objects.hash(invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" + "BillingCycleConfig{invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -25031,6 +27520,7 @@ private constructor( collectionSchedule == other.collectionSchedule && proration == other.proration && subscriptionRate == other.subscriptionRate && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && duration == other.duration && @@ -25048,6 +27538,7 @@ private constructor( collectionSchedule, proration, subscriptionRate, + billingCycleConfig, customFields, description, duration, @@ -25064,7 +27555,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, customFields=$customFields, description=$description, duration=$duration, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, duration=$duration, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" } class UsageStatementSchedule diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageListResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageListResponse.kt index d2f9098a..d7498566 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageListResponse.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageListResponse.kt @@ -5557,6 +5557,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditTemplateIds: JsonField>, private val billingFrequency: JsonField, private val commitTemplateIds: JsonField>, private val presentationGroupValues: JsonField, @@ -5569,6 +5570,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_template_ids") + @ExcludeMissing + anyCommitOrCreditTemplateIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -5591,6 +5595,7 @@ private constructor( @ExcludeMissing recurringCommitTemplateIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditTemplateIds, billingFrequency, commitTemplateIds, presentationGroupValues, @@ -5601,6 +5606,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditTemplateIds(): Optional> = + anyCommitOrCreditTemplateIds.getOptional("any_commit_or_credit_template_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5648,6 +5660,17 @@ private constructor( fun recurringCommitTemplateIds(): Optional> = recurringCommitTemplateIds.getOptional("recurring_commit_template_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditTemplateIds]. + * + * Unlike [anyCommitOrCreditTemplateIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("any_commit_or_credit_template_ids") + @ExcludeMissing + fun _anyCommitOrCreditTemplateIds(): JsonField> = + anyCommitOrCreditTemplateIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -5742,6 +5765,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditTemplateIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitTemplateIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -5754,6 +5778,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditTemplateIds = + overrideSpecifier.anyCommitOrCreditTemplateIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitTemplateIds = overrideSpecifier.commitTemplateIds.map { it.toMutableList() } @@ -5766,6 +5792,36 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditTemplateIds(anyCommitOrCreditTemplateIds: List) = + anyCommitOrCreditTemplateIds(JsonField.of(anyCommitOrCreditTemplateIds)) + + /** + * Sets [Builder.anyCommitOrCreditTemplateIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditTemplateIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditTemplateIds( + anyCommitOrCreditTemplateIds: JsonField> + ) = apply { + this.anyCommitOrCreditTemplateIds = + anyCommitOrCreditTemplateIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditTemplateIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditTemplateId(anyCommitOrCreditTemplateId: String) = apply { + anyCommitOrCreditTemplateIds = + (anyCommitOrCreditTemplateIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditTemplateIds", it) + .add(anyCommitOrCreditTemplateId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -5929,6 +5985,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditTemplateIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitTemplateIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -5957,6 +6014,7 @@ private constructor( return@apply } + anyCommitOrCreditTemplateIds() billingFrequency().ifPresent { it.validate() } commitTemplateIds() presentationGroupValues().ifPresent { it.validate() } @@ -5983,7 +6041,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditTemplateIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitTemplateIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -6396,6 +6455,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditTemplateIds == other.anyCommitOrCreditTemplateIds && billingFrequency == other.billingFrequency && commitTemplateIds == other.commitTemplateIds && presentationGroupValues == other.presentationGroupValues && @@ -6408,6 +6468,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditTemplateIds, billingFrequency, commitTemplateIds, presentationGroupValues, @@ -6422,7 +6483,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitTemplateIds=$commitTemplateIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitTemplateIds=$recurringCommitTemplateIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditTemplateIds=$anyCommitOrCreditTemplateIds, billingFrequency=$billingFrequency, commitTemplateIds=$commitTemplateIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitTemplateIds=$recurringCommitTemplateIds, additionalProperties=$additionalProperties}" } class StartingAtOffset @@ -13211,6 +13272,7 @@ private constructor( private val invoiceAmount: JsonField, private val name: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -13256,6 +13318,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -13283,6 +13348,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -13398,6 +13464,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period defined @@ -13558,6 +13633,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -13645,6 +13730,7 @@ private constructor( private var invoiceAmount: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -13669,6 +13755,7 @@ private constructor( invoiceAmount = recurringCommit.invoiceAmount name = recurringCommit.name proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction specifiers = recurringCommit.specifiers.map { it.toMutableList() } @@ -13891,6 +13978,27 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -14028,6 +14136,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -14066,6 +14175,7 @@ private constructor( invoiceAmount().ifPresent { it.validate() } name() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -14103,6 +14213,7 @@ private constructor( (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -16194,119 +16305,138 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -16319,12 +16449,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -16342,444 +16473,456 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RecurrenceFrequency && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val allocation: JsonField, - private val applySeatIncreaseConfig: JsonField, - private val subscriptionTemplateId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("allocation") + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - @JsonProperty("apply_seat_increase_config") + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_template_id") + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - subscriptionTemplateId: JsonField = JsonMissing.of(), - ) : this(allocation, applySeatIncreaseConfig, subscriptionTemplateId, mutableMapOf()) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun allocation(): Allocation = allocation.getRequired("allocation") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionTemplateId(): String = - subscriptionTemplateId.getRequired("subscription_template_id") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [subscriptionTemplateId]. - * - * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_template_id") - @ExcludeMissing - fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - fun toBuilder() = Builder().from(this) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - companion object { + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var allocation: JsonField? = null - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionTemplateId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - allocation = subscriptionConfig.allocation - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + private var validated: Boolean = false /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - fun subscriptionTemplateId(subscriptionTemplateId: String) = - subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionTemplateId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { - this.subscriptionTemplateId = subscriptionTemplateId - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val HALF_UP = of("HALF_UP") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("allocation", allocation), - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionTemplateId", subscriptionTemplateId), - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply - } - - allocation().validate() - applySeatIncreaseConfig().validate() - subscriptionTemplateId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (allocation.asKnown().getOrNull()?.validity() ?: 0) + - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) - - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - @JvmField val POOLED = of("POOLED") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - INDIVIDUAL, - POOLED, - } + private var validated: Boolean = false - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Allocation] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - POOLED, /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - _UNKNOWN, - } + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED - else -> Value._UNKNOWN + known() + validated = true } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply + return other is RoundingMethod && value == other.value } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Allocation && value == other.value + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } - class ApplySeatIncreaseConfig + class Invoice @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val isProrated: JsonField, + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("is_prorated") + @JsonProperty("decimal_places") @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Indicates whether a mid-period seat increase should be prorated. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Returns the raw JSON value of [isProrated]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("is_prorated") + @JsonProperty("decimal_places") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -16796,42 +16939,63 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. + * Returns a mutable builder for constructing an instance of [Invoice]. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ApplySeatIncreaseConfig]. */ + /** A builder for [Invoice]. */ class Builder internal constructor() { - private var isProrated: JsonField? = null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = apply { @@ -16857,20 +17021,22 @@ private constructor( } /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -16887,12 +17053,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ApplySeatIncreaseConfig = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - isProrated() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -16911,24 +17078,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -16936,1948 +17263,1846 @@ private constructor( return true } - return other is SubscriptionConfig && - allocation == other.allocation && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionTemplateId == other.subscriptionTemplateId && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - allocation, - applySeatIncreaseConfig, - subscriptionTemplateId, - additionalProperties, - ) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is RecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAtOffset == other.startingAtOffset && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - duration == other.duration && - invoiceAmount == other.invoiceAmount && - name == other.name && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - invoiceAmount, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val MONTHLY = of("MONTHLY") - override fun toString() = - "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } + @JvmField val QUARTERLY = of("QUARTERLY") - class RecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val product: JsonField, - private val rateType: JsonField, - private val startingAtOffset: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val duration: JsonField, - private val name: JsonField, - private val proration: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val ANNUAL = of("ANNUAL") - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product") @ExcludeMissing product: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") - @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") - @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") - @ExcludeMissing - subscriptionConfig: JsonField = JsonMissing.of(), - ) : this( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - mutableMapOf(), - ) + @JvmField val WEEKLY = of("WEEKLY") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + @JvmField val DAILY = of("DAILY") - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } - /** - * The amount of time each of the created commits will be valid for - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priority(): Double = priority.getRequired("priority") + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun product(): Product = product.getRequired("product") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } - /** - * Whether the created commits will use the commit rate or list rate - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun rateType(): RateType = rateType.getRequired("rate_type") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } - /** - * Offset relative to the contract start date that determines the start time for the first - * commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun startingAtOffset(): StartingAtOffset = - startingAtOffset.getRequired("starting_at_offset") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + private var validated: Boolean = false - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + known() + validated = true + } - /** - * Offset relative to the recurring credit start that determines when the contract will stop - * creating recurring commits. optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun proration(): Optional = proration.getOptional("proration") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + return other is RecurrenceFrequency && value == other.value + } - /** - * Will be passed down to the individual commits. This controls how much of an individual - * unexpired commit will roll over upon contract transition. Must be between 0 and 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + override fun hashCode() = value.hashCode() - /** - * List of filters that determine what kind of customer usage draws down a commit or credit. - * A customer's usage needs to meet the condition of at least one of the specifiers to - * contribute to a commit's or credit's drawdown. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun specifiers(): Optional> = specifiers.getOptional("specifiers") + override fun toString() = value.toString() + } - /** - * Attach a subscription to the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val applySeatIncreaseConfig: JsonField, + private val subscriptionTemplateId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_template_id") + @ExcludeMissing + subscriptionTemplateId: JsonField = JsonMissing.of(), + ) : this(allocation, applySeatIncreaseConfig, subscriptionTemplateId, mutableMapOf()) - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): Allocation = allocation.getRequired("allocation") - /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionTemplateId(): String = + subscriptionTemplateId.getRequired("subscription_template_id") - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + /** + * Returns the raw JSON value of [applySeatIncreaseConfig]. + * + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + /** + * Returns the raw JSON value of [subscriptionTemplateId]. + * + * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_template_id") + @ExcludeMissing + fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + companion object { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [recurrenceFrequency]. - * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recurrence_frequency") - @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + private var allocation: JsonField? = null + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionTemplateId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + allocation = subscriptionConfig.allocation + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) - /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") - @ExcludeMissing - fun _subscriptionConfig(): JsonField = subscriptionConfig - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } - fun toBuilder() = Builder().from(this) + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) - companion object { + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - /** - * Returns a mutable builder for constructing an instance of [RecurringCredit]. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAtOffset() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun subscriptionTemplateId(subscriptionTemplateId: String) = + subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) - /** A builder for [RecurringCredit]. */ - class Builder internal constructor() { + /** + * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTemplateId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { + this.subscriptionTemplateId = subscriptionTemplateId + } - private var id: JsonField? = null - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var product: JsonField? = null - private var rateType: JsonField? = null - private var startingAtOffset: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmSynthetic - internal fun from(recurringCredit: RecurringCredit) = apply { - id = recurringCredit.id - accessAmount = recurringCredit.accessAmount - commitDuration = recurringCredit.commitDuration - priority = recurringCredit.priority - product = recurringCredit.product - rateType = recurringCredit.rateType - startingAtOffset = recurringCredit.startingAtOffset - applicableProductIds = - recurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - recurringCredit.applicableProductTags.map { it.toMutableList() } - description = recurringCredit.description - duration = recurringCredit.duration - name = recurringCredit.name - proration = recurringCredit.proration - recurrenceFrequency = recurringCredit.recurrenceFrequency - rolloverFraction = recurringCredit.rolloverFraction - specifiers = recurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = recurringCredit.subscriptionConfig - additionalProperties = recurringCredit.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("allocation", allocation), + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionTemplateId", subscriptionTemplateId), + additionalProperties.toMutableMap(), + ) } - /** The amount of time each of the created commits will be valid for */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) + private var validated: Boolean = false /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + allocation().validate() + applySeatIncreaseConfig().validate() + subscriptionTemplateId() + validated = true } - fun priority(priority: Double) = priority(JsonField.of(priority)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.priority] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.priority] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun priority(priority: JsonField) = apply { this.priority = priority } + @JvmSynthetic + internal fun validity(): Int = + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) - fun product(product: Product) = product(JsonField.of(product)) + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun product(product: JsonField) = apply { this.product = product } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + companion object { - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + @JvmField val INDIVIDUAL = of("INDIVIDUAL") - /** - * Offset relative to the contract start date that determines the start time for the - * first commit - */ - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + @JvmField val POOLED = of("POOLED") - /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset - } + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } - /** Will be passed down to the individual commits */ - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN } - } - - /** Will be passed down to the individual commits */ - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) - - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") } - } - fun description(description: String) = description(JsonField.of(description)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + private var validated: Boolean = false - /** - * Offset relative to the recurring credit start that determines when the contract will - * stop creating recurring commits. optional - */ - fun duration(duration: Duration) = duration(JsonField.of(duration)) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } + known() + validated = true + } - fun name(name: String) = name(JsonField.of(name)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + return other is Allocation && value == other.value + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { - this.recurrenceFrequency = recurrenceFrequency + override fun toString() = value.toString() } - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be between - * 0 and 1. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - */ - fun specifiers(specifiers: List) = specifiers(JsonField.of(specifiers)) - - /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - /** - * Adds a single [CommitSpecifier] to [specifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifier) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [SubscriptionConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun subscriptionConfig(subscriptionConfig: JsonField) = apply { - this.subscriptionConfig = subscriptionConfig - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an immutable instance of [RecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAtOffset() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RecurringCredit = - RecurringCredit( - checkRequired("id", id), - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("product", product), - checkRequired("rateType", rateType), - checkRequired("startingAtOffset", startingAtOffset), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } - private var validated: Boolean = false + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): RecurringCredit = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } - id() - accessAmount().validate() - commitDuration().validate() - priority() - product().validate() - rateType().validate() - startingAtOffset().validate() - applicableProductIds() - applicableProductTags() - description() - duration().ifPresent { it.validate() } - name() - proration().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - validated = true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId - - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @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 [AccessAmount]. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { - - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } - - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + additionalProperties.toMutableMap(), + ) } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + private var validated: Boolean = false /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + isProrated() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties } - creditTypeId() - unitPrice() - quantity() - validated = true - } + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && + return other is SubscriptionConfig && + allocation == other.allocation && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionTemplateId == other.subscriptionTemplateId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) - } - - override fun hashCode(): Int = hashCode - + Objects.hash( + allocation, + applySeatIncreaseConfig, + subscriptionTemplateId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" } - /** The amount of time each of the created commits will be valid for */ - class CommitDuration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val value: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): Double = value.getRequired("value") + return other is RecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAtOffset == other.startingAtOffset && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + duration == other.duration && + invoiceAmount == other.invoiceAmount && + name == other.name && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + invoiceAmount, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + override fun toString() = + "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class RecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val product: JsonField, + private val rateType: JsonField, + private val startingAtOffset: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val duration: JsonField, + private val name: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product") @ExcludeMissing product: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = JsonMissing.of(), + ) : this( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + mutableMapOf(), + ) - fun toBuilder() = Builder().from(this) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - companion object { + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") - /** - * Returns a mutable builder for constructing an instance of [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * The amount of time each of the created commits will be valid for + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") - /** A builder for [CommitDuration]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priority(): Double = priority.getRequired("priority") - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun product(): Product = product.getRequired("product") - @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() - } + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rateType(): RateType = rateType.getRequired("rate_type") - fun value(value: Double) = value(JsonField.of(value)) + /** + * Offset relative to the contract start date that determines the start time for the first + * commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingAtOffset(): StartingAtOffset = + startingAtOffset.getRequired("starting_at_offset") - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - fun unit(unit: Unit) = unit(JsonField.of(unit)) + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Offset relative to the recurring credit start that determines when the contract will stop + * creating recurring commits. optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") - /** - * Returns an immutable instance of [CommitDuration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, - additionalProperties.toMutableMap(), - ) - } + /** + * Will be passed down to the individual commits. This controls how much of an individual + * unexpired commit will roll over upon contract transition. Must be between 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") - private var validated: Boolean = false + /** + * List of filters that determine what kind of customer usage draws down a commit or credit. + * A customer's usage needs to meet the condition of at least one of the specifiers to + * contribute to a commit's or credit's drawdown. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun specifiers(): Optional> = specifiers.getOptional("specifiers") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): CommitDuration = apply { - if (validated) { - return@apply - } + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") - value() - unit().ifPresent { it.validate() } - validated = true - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product - companion object { + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType - @JvmField val PERIODS = of("PERIODS") + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } - - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, - /** - * An enum member indicating that [Unit] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - return other is Unit && value == other.value - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = subscriptionConfig - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + companion object { /** - * Returns the raw JSON value of [id]. + * Returns a mutable builder for constructing an instance of [RecurringCredit]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAtOffset() + * ``` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [RecurringCredit]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + private var id: JsonField? = null + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var product: JsonField? = null + private var rateType: JsonField? = null + private var startingAtOffset: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recurringCredit: RecurringCredit) = apply { + id = recurringCredit.id + accessAmount = recurringCredit.accessAmount + commitDuration = recurringCredit.commitDuration + priority = recurringCredit.priority + product = recurringCredit.product + rateType = recurringCredit.rateType + startingAtOffset = recurringCredit.startingAtOffset + applicableProductIds = + recurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + recurringCredit.applicableProductTags.map { it.toMutableList() } + description = recurringCredit.description + duration = recurringCredit.duration + name = recurringCredit.name + proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding + recurrenceFrequency = recurringCredit.recurrenceFrequency + rolloverFraction = recurringCredit.rolloverFraction + specifiers = recurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = recurringCredit.subscriptionConfig + additionalProperties = recurringCredit.additionalProperties.toMutableMap() } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun id(id: String) = id(JsonField.of(id)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } - companion object { + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount } - /** A builder for [Product]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) + /** The amount of time each of the created commits will be valid for */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } - fun name(name: String) = name(JsonField.of(name)) + fun priority(priority: Double) = priority(JsonField.of(priority)) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun product(product: Product) = product(JsonField.of(product)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun product(product: JsonField) = apply { this.product = product } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Offset relative to the contract start date that determines the start time for the + * first commit + */ + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset } - private var validated: Boolean = false + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun validate(): Product = apply { - if (validated) { - return@apply - } + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - id() - name() - validated = true + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } } - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { - /** - * Returns this class instance's raw value. + * Adds a single [String] to [applicableProductTags]. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws IllegalStateException if the field was previously set to a non-list. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } } - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + fun description(description: String) = description(JsonField.of(description)) /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.description] to an arbitrary JSON value. * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - enum class Value { - COMMIT_RATE, - LIST_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown value. - */ - _UNKNOWN, + fun description(description: JsonField) = apply { + this.description = description } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Offset relative to the recurring credit start that determines when the contract will + * stop creating recurring commits. optional */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN - } + fun duration(duration: Duration) = duration(JsonField.of(duration)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.duration] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun name(name: String) = name(JsonField.of(name)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.name] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun name(name: JsonField) = apply { this.name = name } - private var validated: Boolean = false + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.proration] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): RateType = apply { - if (validated) { - return@apply - } + fun proration(proration: JsonField) = apply { this.proration = proration } - known() - validated = true - } + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) - /** - * Offset relative to the contract start date that determines the start time for the first - * commit - */ - class StartingAtOffset - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unit: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { + this.recurrenceFrequency = recurrenceFrequency + } - @JsonCreator - private constructor( - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(unit, value, mutableMapOf()) + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be between + * 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun unit(): Unit = unit.getRequired("unit") + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. */ - fun value(): Long = value.getRequired("value") + fun specifiers(specifiers: List) = specifiers(JsonField.of(specifiers)) /** - * Returns the raw JSON value of [unit]. + * Sets [Builder.specifiers] to an arbitrary JSON value. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } /** - * Returns the raw JSON value of [value]. + * Adds a single [CommitSpecifier] to [specifiers]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun addSpecifier(specifier: CommitSpecifier) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [SubscriptionConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionConfig(subscriptionConfig: JsonField) = apply { + this.subscriptionConfig = subscriptionConfig + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAtOffset() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringCredit = + RecurringCredit( + checkRequired("id", id), + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("product", product), + checkRequired("rateType", rateType), + checkRequired("startingAtOffset", startingAtOffset), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RecurringCredit = apply { + if (validated) { + return@apply + } + + id() + accessAmount().validate() + commitDuration().validate() + priority() + product().validate() + rateType().validate() + startingAtOffset().validate() + applicableProductIds() + applicableProductTags() + description() + duration().ifPresent { it.validate() } + name() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } @JsonAnyGetter @@ -18890,52 +19115,67 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [StartingAtOffset]. + * Returns a mutable builder for constructing an instance of [AccessAmount]. * * The following fields are required: * ```java - * .unit() - * .value() + * .creditTypeId() + * .unitPrice() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [StartingAtOffset]. */ + /** A builder for [AccessAmount]. */ class Builder internal constructor() { - private var unit: JsonField? = null - private var value: JsonField? = null + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(startingAtOffset: StartingAtOffset) = apply { - unit = startingAtOffset.unit - value = startingAtOffset.value - additionalProperties = startingAtOffset.additionalProperties.toMutableMap() + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() } - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) /** - * Sets [Builder.unit] to an arbitrary JSON value. + * Sets [Builder.creditTypeId] to an arbitrary JSON value. * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - fun value(value: Long) = value(JsonField.of(value)) + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -18960,22 +19200,23 @@ private constructor( } /** - * Returns an immutable instance of [StartingAtOffset]. + * Returns an immutable instance of [AccessAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unit() - * .value() + * .creditTypeId() + * .unitPrice() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): StartingAtOffset = - StartingAtOffset( - checkRequired("unit", unit), - checkRequired("value", value), + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, additionalProperties.toMutableMap(), ) } @@ -18992,13 +19233,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): StartingAtOffset = apply { + fun validate(): AccessAmount = apply { if (validated) { return@apply } - unit().validate() - value() + creditTypeId() + unitPrice() + quantity() validated = true } @@ -19018,225 +19260,73 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAYS = of("DAYS") - - @JvmField val WEEKS = of("WEEKS") - - @JvmField val MONTHS = of("MONTHS") - - @JvmField val YEARS = of("YEARS") - - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } - - /** An enum containing [Unit]'s known values. */ - enum class Known { - DAYS, - WEEKS, - MONTHS, - YEARS, - } - - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAYS, - WEEKS, - MONTHS, - YEARS, - /** - * An enum member indicating that [Unit] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAYS -> Value.DAYS - WEEKS -> Value.WEEKS - MONTHS -> Value.MONTHS - YEARS -> Value.YEARS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAYS -> Known.DAYS - WEEKS -> Known.WEEKS - MONTHS -> Known.MONTHS - YEARS -> Known.YEARS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Unit && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is StartingAtOffset && - unit == other.unit && - value == other.value && + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" } - /** - * Offset relative to the recurring credit start that determines when the contract will stop - * creating recurring commits. optional - */ - class Duration + /** The amount of time each of the created commits will be valid for */ + class CommitDuration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val value: JsonField, private val unit: JsonField, - private val value: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(unit, value, mutableMapOf()) + ) : this(value, unit, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unit(): Unit = unit.getRequired("unit") + fun value(): Double = value.getRequired("value") /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun value(): Long = value.getRequired("value") + fun unit(): Optional = unit.getOptional("unit") /** - * Returns the raw JSON value of [unit]. + * Returns the raw JSON value of [value]. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [unit]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19253,52 +19343,51 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Duration]. + * Returns a mutable builder for constructing an instance of [CommitDuration]. * * The following fields are required: * ```java - * .unit() * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Duration]. */ + /** A builder for [CommitDuration]. */ class Builder internal constructor() { - private var unit: JsonField? = null - private var value: JsonField? = null + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(duration: Duration) = apply { - unit = duration.unit - value = duration.value - additionalProperties = duration.additionalProperties.toMutableMap() + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() } - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun value(value: Double) = value(JsonField.of(value)) /** - * Sets [Builder.unit] to an arbitrary JSON value. + * Sets [Builder.value] to an arbitrary JSON value. * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * You should usually call [Builder.value] with a well-typed [Double] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun unit(unit: JsonField) = apply { this.unit = unit } + fun value(value: JsonField) = apply { this.value = value } - fun value(value: Long) = value(JsonField.of(value)) + fun unit(unit: Unit) = unit(JsonField.of(unit)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.unit] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Long] value instead. + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun unit(unit: JsonField) = apply { this.unit = unit } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -19323,22 +19412,21 @@ private constructor( } /** - * Returns an immutable instance of [Duration]. + * Returns an immutable instance of [CommitDuration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unit() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Duration = - Duration( - checkRequired("unit", unit), + fun build(): CommitDuration = + CommitDuration( checkRequired("value", value), + unit, additionalProperties.toMutableMap(), ) } @@ -19355,13 +19443,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Duration = apply { + fun validate(): CommitDuration = apply { if (validated) { return@apply } - unit().validate() value() + unit().ifPresent { it.validate() } validated = true } @@ -19381,8 +19469,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) class Unit @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -19399,23 +19487,14 @@ private constructor( companion object { - @JvmField val DAYS = of("DAYS") - - @JvmField val WEEKS = of("WEEKS") - - @JvmField val MONTHS = of("MONTHS") - - @JvmField val YEARS = of("YEARS") + @JvmField val PERIODS = of("PERIODS") @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) } /** An enum containing [Unit]'s known values. */ enum class Known { - DAYS, - WEEKS, - MONTHS, - YEARS, + PERIODS } /** @@ -19428,10 +19507,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - DAYS, - WEEKS, - MONTHS, - YEARS, + PERIODS, /** * An enum member indicating that [Unit] was instantiated with an unknown value. */ @@ -19447,10 +19523,7 @@ private constructor( */ fun value(): Value = when (this) { - DAYS -> Value.DAYS - WEEKS -> Value.WEEKS - MONTHS -> Value.MONTHS - YEARS -> Value.YEARS + PERIODS -> Value.PERIODS else -> Value._UNKNOWN } @@ -19465,10 +19538,7 @@ private constructor( */ fun known(): Known = when (this) { - DAYS -> Known.DAYS - WEEKS -> Known.WEEKS - MONTHS -> Known.MONTHS - YEARS -> Known.YEARS + PERIODS -> Known.PERIODS else -> throw MetronomeInvalidDataException("Unknown Unit: $value") } @@ -19541,186 +19611,229 @@ private constructor( return true } - return other is Duration && - unit == other.unit && + return other is CommitDuration && value == other.value && + unit == other.unit && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" } - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val NONE = of("NONE") - - @JvmField val FIRST = of("FIRST") - - @JvmField val LAST = of("LAST") - - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") - - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } - - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + fun id(): String = id.getRequired("id") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + fun name(): String = name.getRequired("name") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [id]. * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns the raw JSON value of [name]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun validate(): Proration = apply { - if (validated) { - return@apply - } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - known() - validated = true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Proration && value == other.value + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - override fun hashCode() = value.hashCode() + /** A builder for [Product]. */ + class Builder internal constructor() { - override fun toString() = value.toString() + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Product = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -19734,44 +19847,33 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val LIST_RATE = of("LIST_RATE") - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) } - /** An enum containing [RecurrenceFrequency]'s known values. */ + /** An enum containing [RateType]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + COMMIT_RATE, + LIST_RATE, } /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: + * An instance of [RateType] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + COMMIT_RATE, + LIST_RATE, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * An enum member indicating that [RateType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -19785,10 +19887,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE else -> Value._UNKNOWN } @@ -19803,12 +19903,9 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") } /** @@ -19837,7 +19934,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): RateType = apply { if (validated) { return@apply } @@ -19867,7 +19964,7 @@ private constructor( return true } - return other is RecurrenceFrequency && value == other.value + return other is RateType && value == other.value } override fun hashCode() = value.hashCode() @@ -19875,82 +19972,51 @@ private constructor( override fun toString() = value.toString() } - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig + /** + * Offset relative to the contract start date that determines the start time for the first + * commit + */ + class StartingAtOffset @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val allocation: JsonField, - private val applySeatIncreaseConfig: JsonField, - private val subscriptionTemplateId: JsonField, + private val unit: JsonField, + private val value: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_template_id") - @ExcludeMissing - subscriptionTemplateId: JsonField = JsonMissing.of(), - ) : this(allocation, applySeatIncreaseConfig, subscriptionTemplateId, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun allocation(): Allocation = allocation.getRequired("allocation") + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(unit, value, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + fun unit(): Unit = unit.getRequired("unit") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun subscriptionTemplateId(): String = - subscriptionTemplateId.getRequired("subscription_template_id") + fun value(): Long = value.getRequired("value") /** - * Returns the raw JSON value of [allocation]. + * Returns the raw JSON value of [unit]. * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. + * Returns the raw JSON value of [value]. * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig - - /** - * Returns the raw JSON value of [subscriptionTemplateId]. - * - * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_template_id") - @ExcludeMissing - fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19967,74 +20033,52 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. + * Returns a mutable builder for constructing an instance of [StartingAtOffset]. * * The following fields are required: * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() + * .unit() + * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionConfig]. */ + /** A builder for [StartingAtOffset]. */ class Builder internal constructor() { - private var allocation: JsonField? = null - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionTemplateId: JsonField? = null + private var unit: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - allocation = subscriptionConfig.allocation - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() - } - - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) - - /** - * Sets [Builder.allocation] to an arbitrary JSON value. - * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation + internal fun from(startingAtOffset: StartingAtOffset) = apply { + unit = startingAtOffset.unit + value = startingAtOffset.value + additionalProperties = startingAtOffset.additionalProperties.toMutableMap() } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + fun unit(unit: Unit) = unit(JsonField.of(unit)) /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Sets [Builder.unit] to an arbitrary JSON value. * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + fun unit(unit: JsonField) = apply { this.unit = unit } - fun subscriptionTemplateId(subscriptionTemplateId: String) = - subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + fun value(value: Long) = value(JsonField.of(value)) /** - * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. + * Sets [Builder.value] to an arbitrary JSON value. * - * You should usually call [Builder.subscriptionTemplateId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.value] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { - this.subscriptionTemplateId = subscriptionTemplateId - } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -20059,24 +20103,22 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionConfig]. + * Returns an immutable instance of [StartingAtOffset]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() + * .unit() + * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("allocation", allocation), - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionTemplateId", subscriptionTemplateId), + fun build(): StartingAtOffset = + StartingAtOffset( + checkRequired("unit", unit), + checkRequired("value", value), additionalProperties.toMutableMap(), ) } @@ -20093,14 +20135,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): SubscriptionConfig = apply { + fun validate(): StartingAtOffset = apply { if (validated) { return@apply } - allocation().validate() - applySeatIncreaseConfig().validate() - subscriptionTemplateId() + unit().validate() + value() validated = true } @@ -20120,13 +20161,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (allocation.asKnown().getOrNull()?.validity() ?: 0) + - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -20140,34 +20179,41 @@ private constructor( companion object { - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + @JvmField val DAYS = of("DAYS") - @JvmField val POOLED = of("POOLED") + @JvmField val WEEKS = of("WEEKS") - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + @JvmField val MONTHS = of("MONTHS") + + @JvmField val YEARS = of("YEARS") + + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) } - /** An enum containing [Allocation]'s known values. */ + /** An enum containing [Unit]'s known values. */ enum class Known { - INDIVIDUAL, - POOLED, + DAYS, + WEEKS, + MONTHS, + YEARS, } /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Allocation] can contain an unknown value in a couple of cases: + * An instance of [Unit] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - INDIVIDUAL, - POOLED, + DAYS, + WEEKS, + MONTHS, + YEARS, /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. + * An enum member indicating that [Unit] was instantiated with an unknown value. */ _UNKNOWN, } @@ -20181,8 +20227,10 @@ private constructor( */ fun value(): Value = when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED + DAYS -> Value.DAYS + WEEKS -> Value.WEEKS + MONTHS -> Value.MONTHS + YEARS -> Value.YEARS else -> Value._UNKNOWN } @@ -20197,9 +20245,11 @@ private constructor( */ fun known(): Known = when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + DAYS -> Known.DAYS + WEEKS -> Known.WEEKS + MONTHS -> Known.MONTHS + YEARS -> Known.YEARS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") } /** @@ -20228,7 +20278,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Allocation = apply { + fun validate(): Unit = apply { if (validated) { return@apply } @@ -20258,7 +20308,7 @@ private constructor( return true } - return other is Allocation && value == other.value + return other is Unit && value == other.value } override fun hashCode() = value.hashCode() @@ -20266,927 +20316,1210 @@ private constructor( override fun toString() = value.toString() } - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + return other is StartingAtOffset && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated + private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun toString() = + "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + } - fun toBuilder() = Builder().from(this) + /** + * Offset relative to the recurring credit start that determines when the contract will stop + * creating recurring commits. optional + */ + class Duration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unit: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(unit, value, mutableMapOf()) - /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unit(): Unit = unit.getRequired("unit") - /** A builder for [ApplySeatIncreaseConfig]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): Long = value.getRequired("value") - private var isProrated: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.isProrated] to an arbitrary JSON value. - * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [Duration]. + * + * The following fields are required: + * ```java + * .unit() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Duration]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var unit: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), - additionalProperties.toMutableMap(), - ) + @JvmSynthetic + internal fun from(duration: Duration) = apply { + unit = duration.unit + value = duration.value + additionalProperties = duration.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun unit(unit: Unit) = unit(JsonField.of(unit)) /** - * Validates that the types of all values in this object match their expected types - * recursively. + * Sets [Builder.unit] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun value(value: Long) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.value] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): ApplySeatIncreaseConfig = apply { - if (validated) { - return@apply - } + fun value(value: JsonField) = apply { this.value = value } - isProrated() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Duration]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unit() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + fun build(): Duration = + Duration( + checkRequired("unit", unit), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Duration = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + unit().validate() + value() + validated = true } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - return other is SubscriptionConfig && - allocation == other.allocation && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionTemplateId == other.subscriptionTemplateId && - additionalProperties == other.additionalProperties - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) - private val hashCode: Int by lazy { - Objects.hash( - allocation, - applySeatIncreaseConfig, - subscriptionTemplateId, - additionalProperties, - ) - } + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun hashCode(): Int = hashCode + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun toString() = - "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val DAYS = of("DAYS") - return other is RecurringCredit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAtOffset == other.startingAtOffset && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - duration == other.duration && - name == other.name && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + @JvmField val WEEKS = of("WEEKS") - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) - } + @JvmField val MONTHS = of("MONTHS") - override fun hashCode(): Int = hashCode + @JvmField val YEARS = of("YEARS") - override fun toString() = - "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } - /** - * Determines which scheduled and commit charges to consolidate onto the Contract's usage - * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for - * consolidation to occur. This field cannot be modified after a Contract has been created. If - * this field is omitted, charges will appear on a separate invoice from usage charges. - */ - class ScheduledChargesOnUsageInvoices - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [Unit]'s known values. */ + enum class Known { + DAYS, + WEEKS, + MONTHS, + YEARS, + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAYS, + WEEKS, + MONTHS, + YEARS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown value. + */ + _UNKNOWN, + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAYS -> Value.DAYS + WEEKS -> Value.WEEKS + MONTHS -> Value.MONTHS + YEARS -> Value.YEARS + else -> Value._UNKNOWN + } - @JvmField val ALL = of("ALL") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DAYS -> Known.DAYS + WEEKS -> Known.WEEKS + MONTHS -> Known.MONTHS + YEARS -> Known.YEARS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } - @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ - enum class Known { - ALL + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Duration && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(unit, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" } /** - * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). */ - enum class Value { - ALL, + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + /** - * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated - * with an unknown value. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - _UNKNOWN, - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - else -> Value._UNKNOWN - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - else -> - throw MetronomeInvalidDataException( - "Unknown ScheduledChargesOnUsageInvoices: $value" - ) - } + @JvmField val NONE = of("NONE") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JvmField val FIRST = of("FIRST") - private var validated: Boolean = false + @JvmField val LAST = of("LAST") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ScheduledChargesOnUsageInvoices = apply { - if (validated) { - return@apply + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) } - known() - validated = true - } + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true } - return other is ScheduledChargesOnUsageInvoices && value == other.value - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun hashCode() = value.hashCode() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = value.toString() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - class SpendTracker - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val alias: JsonField, - private val applicableSpendSpecifiers: JsonField>, - private val creditTypeId: JsonField, - private val resetFrequency: JsonField, - private val additionalProperties: MutableMap, - ) { + return other is Proration && value == other.value + } - @JsonCreator + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - applicableSpendSpecifiers: JsonField> = JsonMissing.of(), - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("reset_frequency") - @ExcludeMissing - resetFrequency: JsonField = JsonMissing.of(), - ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Human-readable identifier, unique per contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun alias(): String = alias.getRequired("alias") + @JsonCreator + private constructor( + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun applicableSpendSpecifiers(): List = - applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [applicableSpendSpecifiers]. - * - * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - fun _applicableSpendSpecifiers(): JsonField> = - applicableSpendSpecifiers - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [resetFrequency]. - * - * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reset_frequency") - @ExcludeMissing - fun _resetFrequency(): JsonField = resetFrequency + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of [SpendTracker]. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun access(access: Access) = access(JsonField.of(access)) - /** A builder for [SpendTracker]. */ - class Builder internal constructor() { + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } - private var alias: JsonField? = null - private var applicableSpendSpecifiers: - JsonField>? = - null - private var creditTypeId: JsonField? = null - private var resetFrequency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmSynthetic - internal fun from(spendTracker: SpendTracker) = apply { - alias = spendTracker.alias - applicableSpendSpecifiers = - spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } - creditTypeId = spendTracker.creditTypeId - resetFrequency = spendTracker.resetFrequency - additionalProperties = spendTracker.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Human-readable identifier, unique per contract. */ - fun alias(alias: String) = alias(JsonField.of(alias)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.alias] to an arbitrary JSON value. - * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun alias(alias: JsonField) = apply { this.alias = alias } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: List - ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: JsonField> - ) = apply { - this.applicableSpendSpecifiers = - applicableSpendSpecifiers.map { it.toMutableList() } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) } + private var validated: Boolean = false + /** - * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = - apply { - applicableSpendSpecifiers = - (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableSpendSpecifiers", it) - .add(applicableSpendSpecifier) - } + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + access().ifPresent { it.validate() } + validated = true } - fun resetFrequency(resetFrequency: ResetFrequency) = - resetFrequency(JsonField.of(resetFrequency)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Used for best match union deserialization. */ - fun resetFrequency(resetFrequency: JsonField) = apply { - this.resetFrequency = resetFrequency - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** - * Returns an immutable instance of [SpendTracker]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SpendTracker = - SpendTracker( - checkRequired("alias", alias), - checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { - it.toImmutable() - }, - checkRequired("creditTypeId", creditTypeId), - checkRequired("resetFrequency", resetFrequency), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - private var validated: Boolean = false + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): SpendTracker = apply { - if (validated) { - return@apply - } - - alias() - applicableSpendSpecifiers().forEach { it.validate() } - creditTypeId() - resetFrequency().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (alias.asKnown().isPresent) 1 else 0) + - (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class ApplicableSpendSpecifier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sources: JsonField>, - private val spendType: JsonField, - private val discounted: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("sources") - @ExcludeMissing - sources: JsonField> = JsonMissing.of(), - @JsonProperty("spend_type") - @ExcludeMissing - spendType: JsonField = JsonMissing.of(), - @JsonProperty("discounted") - @ExcludeMissing - discounted: JsonField = JsonMissing.of(), - ) : this(sources, spendType, discounted, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun sources(): List = sources.getRequired("sources") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun spendType(): SpendType = spendType.getRequired("spend_type") + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun discounted(): Optional = discounted.getOptional("discounted") + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [sources]. - * - * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sources") - @ExcludeMissing - fun _sources(): JsonField> = sources + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [spendType]. - * - * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("spend_type") - @ExcludeMissing - fun _spendType(): JsonField = spendType + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Returns the raw JSON value of [discounted]. - * - * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discounted") - @ExcludeMissing - fun _discounted(): JsonField = discounted + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [ApplicableSpendSpecifier]. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [ApplicableSpendSpecifier]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var sources: JsonField>? = null - private var spendType: JsonField? = null - private var discounted: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { - sources = applicableSpendSpecifier.sources.map { it.toMutableList() } - spendType = applicableSpendSpecifier.spendType - discounted = applicableSpendSpecifier.discounted - additionalProperties = - applicableSpendSpecifier.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - fun sources(sources: List) = sources(JsonField.of(sources)) + private var validated: Boolean = false /** - * Sets [Builder.sources] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.sources] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sources(sources: JsonField>) = apply { - this.sources = sources.map { it.toMutableList() } - } - - /** - * Adds a single [Source] to [sources]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun addSource(source: Source) = apply { - sources = - (sources ?: JsonField.of(mutableListOf())).also { - checkKnown("sources", it).add(source) - } + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } - fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.spendType] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.spendType] with a well-typed [SpendType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Used for best match union deserialization. */ - fun spendType(spendType: JsonField) = apply { - this.spendType = spendType - } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.discounted] to an arbitrary JSON value. - * - * You should usually call [Builder.discounted] with a well-typed [Discounted] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun discounted(discounted: JsonField) = apply { - this.discounted = discounted - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, /** - * Returns an immutable instance of [ApplicableSpendSpecifier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. */ - fun build(): ApplicableSpendSpecifier = - ApplicableSpendSpecifier( - checkRequired("sources", sources).map { it.toImmutable() }, - checkRequired("spendType", spendType), - discounted, - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -21199,14 +21532,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ApplicableSpendSpecifier = apply { + fun validate(): RecurrenceFrequency = apply { if (validated) { return@apply } - sources().forEach { it.validate() } - spendType().validate() - discounted().ifPresent { it.validate() } + known() validated = true } @@ -21224,459 +21555,2671 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (spendType.asKnown().getOrNull()?.validity() ?: 0) + - (discounted.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - class Source @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val applySeatIncreaseConfig: JsonField, + private val subscriptionTemplateId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_template_id") + @ExcludeMissing + subscriptionTemplateId: JsonField = JsonMissing.of(), + ) : this(allocation, applySeatIncreaseConfig, subscriptionTemplateId, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): Allocation = allocation.getRequired("allocation") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionTemplateId(): String = + subscriptionTemplateId.getRequired("subscription_template_id") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [applySeatIncreaseConfig]. + * + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig + + /** + * Returns the raw JSON value of [subscriptionTemplateId]. + * + * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_template_id") + @ExcludeMissing + fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId + + @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 this class instance's raw value. + * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + @JvmStatic fun builder() = Builder() + } - @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { - @JvmField val MANUAL = of("MANUAL") + private var allocation: JsonField? = null + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionTemplateId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + allocation = subscriptionConfig.allocation + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() } - /** An enum containing [Source]'s known values. */ - enum class Known { - THRESHOLD_RECHARGE, - MANUAL, - } + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) /** - * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.allocation] to an arbitrary JSON value. * - * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - enum class Value { - THRESHOLD_RECHARGE, - MANUAL, - /** - * An enum member indicating that [Source] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation } + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun value(): Value = - when (this) { - THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE - MANUAL -> Value.MANUAL - else -> Value._UNKNOWN - } + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + + fun subscriptionTemplateId(subscriptionTemplateId: String) = + subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.subscriptionTemplateId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE - MANUAL -> Known.MANUAL - else -> throw MetronomeInvalidDataException("Unknown Source: $value") + fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { + this.subscriptionTemplateId = subscriptionTemplateId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns this class instance's primitive wire representation. + * Returns an immutable instance of [SubscriptionConfig]. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("allocation", allocation), + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionTemplateId", subscriptionTemplateId), + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + allocation().validate() + applySeatIncreaseConfig().validate() + subscriptionTemplateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) + + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmField val POOLED = of("POOLED") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } + + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } + + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allocation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) + + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + @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 + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { + + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } + + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } + + isProrated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionConfig && + allocation == other.allocation && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionTemplateId == other.subscriptionTemplateId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocation, + applySeatIncreaseConfig, + subscriptionTemplateId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurringCredit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAtOffset == other.startingAtOffset && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + duration == other.duration && + name == other.name && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } + + /** + * Determines which scheduled and commit charges to consolidate onto the Contract's usage + * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for + * consolidation to occur. This field cannot be modified after a Contract has been created. If + * this field is omitted, charges will appear on a separate invoice from usage charges. + */ + class ScheduledChargesOnUsageInvoices + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("ALL") + + @JvmStatic fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) + } + + /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ + enum class Known { + ALL + } + + /** + * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + /** + * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + else -> + throw MetronomeInvalidDataException( + "Unknown ScheduledChargesOnUsageInvoices: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScheduledChargesOnUsageInvoices = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduledChargesOnUsageInvoices && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SpendTracker + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val alias: JsonField, + private val applicableSpendSpecifiers: JsonField>, + private val creditTypeId: JsonField, + private val resetFrequency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + applicableSpendSpecifiers: JsonField> = JsonMissing.of(), + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("reset_frequency") + @ExcludeMissing + resetFrequency: JsonField = JsonMissing.of(), + ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + + /** + * Human-readable identifier, unique per contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun alias(): String = alias.getRequired("alias") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun applicableSpendSpecifiers(): List = + applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + + /** + * Returns the raw JSON value of [applicableSpendSpecifiers]. + * + * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + fun _applicableSpendSpecifiers(): JsonField> = + applicableSpendSpecifiers + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [resetFrequency]. + * + * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reset_frequency") + @ExcludeMissing + fun _resetFrequency(): JsonField = resetFrequency + + @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 [SpendTracker]. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendTracker]. */ + class Builder internal constructor() { + + private var alias: JsonField? = null + private var applicableSpendSpecifiers: + JsonField>? = + null + private var creditTypeId: JsonField? = null + private var resetFrequency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spendTracker: SpendTracker) = apply { + alias = spendTracker.alias + applicableSpendSpecifiers = + spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } + creditTypeId = spendTracker.creditTypeId + resetFrequency = spendTracker.resetFrequency + additionalProperties = spendTracker.additionalProperties.toMutableMap() + } + + /** Human-readable identifier, unique per contract. */ + fun alias(alias: String) = alias(JsonField.of(alias)) + + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } + + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: List + ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + + /** + * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: JsonField> + ) = apply { + this.applicableSpendSpecifiers = + applicableSpendSpecifiers.map { it.toMutableList() } + } + + /** + * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = + apply { + applicableSpendSpecifiers = + (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableSpendSpecifiers", it) + .add(applicableSpendSpecifier) + } + } + + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun resetFrequency(resetFrequency: ResetFrequency) = + resetFrequency(JsonField.of(resetFrequency)) + + /** + * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun resetFrequency(resetFrequency: JsonField) = apply { + this.resetFrequency = resetFrequency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SpendTracker]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendTracker = + SpendTracker( + checkRequired("alias", alias), + checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { + it.toImmutable() + }, + checkRequired("creditTypeId", creditTypeId), + checkRequired("resetFrequency", resetFrequency), + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SpendTracker = apply { + if (validated) { + return@apply + } + + alias() + applicableSpendSpecifiers().forEach { it.validate() } + creditTypeId() + resetFrequency().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (alias.asKnown().isPresent) 1 else 0) + + (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + + class ApplicableSpendSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sources: JsonField>, + private val spendType: JsonField, + private val discounted: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sources") + @ExcludeMissing + sources: JsonField> = JsonMissing.of(), + @JsonProperty("spend_type") + @ExcludeMissing + spendType: JsonField = JsonMissing.of(), + @JsonProperty("discounted") + @ExcludeMissing + discounted: JsonField = JsonMissing.of(), + ) : this(sources, spendType, discounted, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun sources(): List = sources.getRequired("sources") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun spendType(): SpendType = spendType.getRequired("spend_type") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun discounted(): Optional = discounted.getOptional("discounted") + + /** + * Returns the raw JSON value of [sources]. + * + * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sources") + @ExcludeMissing + fun _sources(): JsonField> = sources + + /** + * Returns the raw JSON value of [spendType]. + * + * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spend_type") + @ExcludeMissing + fun _spendType(): JsonField = spendType + + /** + * Returns the raw JSON value of [discounted]. + * + * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discounted") + @ExcludeMissing + fun _discounted(): JsonField = discounted + + @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 + * [ApplicableSpendSpecifier]. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplicableSpendSpecifier]. */ + class Builder internal constructor() { + + private var sources: JsonField>? = null + private var spendType: JsonField? = null + private var discounted: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { + sources = applicableSpendSpecifier.sources.map { it.toMutableList() } + spendType = applicableSpendSpecifier.spendType + discounted = applicableSpendSpecifier.discounted + additionalProperties = + applicableSpendSpecifier.additionalProperties.toMutableMap() + } + + fun sources(sources: List) = sources(JsonField.of(sources)) + + /** + * Sets [Builder.sources] to an arbitrary JSON value. + * + * You should usually call [Builder.sources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sources(sources: JsonField>) = apply { + this.sources = sources.map { it.toMutableList() } + } + + /** + * Adds a single [Source] to [sources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: Source) = apply { + sources = + (sources ?: JsonField.of(mutableListOf())).also { + checkKnown("sources", it).add(source) + } + } + + fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + + /** + * Sets [Builder.spendType] to an arbitrary JSON value. + * + * You should usually call [Builder.spendType] with a well-typed [SpendType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun spendType(spendType: JsonField) = apply { + this.spendType = spendType + } + + fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + + /** + * Sets [Builder.discounted] to an arbitrary JSON value. + * + * You should usually call [Builder.discounted] with a well-typed [Discounted] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun discounted(discounted: JsonField) = apply { + this.discounted = discounted + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplicableSpendSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplicableSpendSpecifier = + ApplicableSpendSpecifier( + checkRequired("sources", sources).map { it.toImmutable() }, + checkRequired("spendType", spendType), + discounted, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ApplicableSpendSpecifier = apply { + if (validated) { + return@apply + } + + sources().forEach { it.validate() } + spendType().validate() + discounted().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (spendType.asKnown().getOrNull()?.validity() ?: 0) + + (discounted.asKnown().getOrNull()?.validity() ?: 0) + + class Source @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + + @JvmField val MANUAL = of("MANUAL") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + THRESHOLD_RECHARGE, + MANUAL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_RECHARGE, + MANUAL, + /** + * An enum member indicating that [Source] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE + MANUAL -> Known.MANUAL + else -> throw MetronomeInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class SpendType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + + @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) + } + + /** An enum containing [SpendType]'s known values. */ + enum class Known { + COMMIT_PURCHASE + } + + /** + * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SpendType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_PURCHASE, + /** + * An enum member indicating that [SpendType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_PURCHASE -> Value.COMMIT_PURCHASE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_PURCHASE -> Known.COMMIT_PURCHASE + else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SpendType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Discounted + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANY = of("ANY") + + @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + + @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + + @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) + } + + /** An enum containing [Discounted]'s known values. */ + enum class Known { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + } + + /** + * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Discounted] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + /** + * An enum member indicating that [Discounted] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANY -> Value.ANY + DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANY -> Known.ANY + DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY + else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Discounted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Discounted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplicableSpendSpecifier && + sources == other.sources && + spendType == other.spendType && + discounted == other.discounted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sources, spendType, discounted, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + } + + class ResetFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + + @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + } + + /** An enum containing [ResetFrequency]'s known values. */ + enum class Known { + BILLING_PERIOD + } + + /** + * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILLING_PERIOD, + /** + * An enum member indicating that [ResetFrequency] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILLING_PERIOD -> Value.BILLING_PERIOD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BILLING_PERIOD -> Known.BILLING_PERIOD + else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ResetFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResetFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendTracker && + alias == other.alias && + applicableSpendSpecifiers == other.applicableSpendSpecifiers && + creditTypeId == other.creditTypeId && + resetFrequency == other.resetFrequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + alias, + applicableSpendSpecifiers, + creditTypeId, + resetFrequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" + } + + class Subscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val subscriptionRate: JsonField, + private val id: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val fiatCreditTypeId: JsonField, + private val initialQuantity: JsonField, + private val name: JsonField, + private val quantityManagementMode: JsonField, + private val seatConfig: JsonField, + private val startingAtOffset: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fiatCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("initial_quantity") + @ExcludeMissing + initialQuantity: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + ) : this( + collectionSchedule, + proration, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + duration, + fiatCreditTypeId, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun proration(): Proration = proration.getRequired("proration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") + + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fiatCreditTypeId(): Optional = + fiatCreditTypeId.getOptional("fiat_credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a SEAT_BASED + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantityManagementMode(): Optional = + quantityManagementMode.getOptional("quantity_management_mode") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - private var validated: Boolean = false + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAtOffset(): Optional = + startingAtOffset.getOptional("starting_at_offset") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Source = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - known() - validated = true - } + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - return other is Source && value == other.value - } + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - class SpendType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [fiatCreditTypeId]. + * + * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [initialQuantity]. + * + * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_quantity") + @ExcludeMissing + fun _initialQuantity(): JsonField = initialQuantity - companion object { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = quantityManagementMode - @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - /** An enum containing [SpendType]'s known values. */ - enum class Known { - COMMIT_PURCHASE - } + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset - /** - * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [SpendType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_PURCHASE, - /** - * An enum member indicating that [SpendType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_PURCHASE -> Value.COMMIT_PURCHASE - else -> Value._UNKNOWN - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_PURCHASE -> Known.COMMIT_PURCHASE - else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") - } + fun toBuilder() = Builder().from(this) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Subscription]. */ + class Builder internal constructor() { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SpendType = apply { - if (validated) { - return@apply - } + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var subscriptionRate: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var fiatCreditTypeId: JsonField = JsonMissing.of() + private var initialQuantity: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quantityManagementMode: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var startingAtOffset: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - known() - validated = true - } + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + collectionSchedule = subscription.collectionSchedule + proration = subscription.proration + subscriptionRate = subscription.subscriptionRate + id = subscription.id + billingCycleConfig = subscription.billingCycleConfig + customFields = subscription.customFields + description = subscription.description + duration = subscription.duration + fiatCreditTypeId = subscription.fiatCreditTypeId + initialQuantity = subscription.initialQuantity + name = subscription.name + quantityManagementMode = subscription.quantityManagementMode + seatConfig = subscription.seatConfig + startingAtOffset = subscription.startingAtOffset + additionalProperties = subscription.additionalProperties.toMutableMap() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun proration(proration: Proration) = proration(JsonField.of(proration)) - return other is SpendType && value == other.value - } + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } - override fun hashCode() = value.hashCode() + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - override fun toString() = value.toString() + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate } - class Discounted - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } - companion object { + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) - @JvmField val ANY = of("ANY") + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } - @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) - @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } - @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) - } + fun description(description: String) = description(JsonField.of(description)) - /** An enum containing [Discounted]'s known values. */ - enum class Known { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Discounted] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - /** - * An enum member indicating that [Discounted] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun duration(duration: Duration) = duration(JsonField.of(duration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANY -> Value.ANY - DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY - else -> Value._UNKNOWN - } + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANY -> Known.ANY - DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY - else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") - } + fun fiatCreditTypeId(fiatCreditTypeId: String) = + fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { + this.fiatCreditTypeId = fiatCreditTypeId + } + + fun initialQuantity(initialQuantity: Double) = + initialQuantity(JsonField.of(initialQuantity)) - private var validated: Boolean = false + /** + * Sets [Builder.initialQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.initialQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun initialQuantity(initialQuantity: JsonField) = apply { + this.initialQuantity = initialQuantity + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Discounted = apply { - if (validated) { - return@apply - } + fun name(name: String) = name(JsonField.of(name)) - known() - validated = true - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * SEAT_BASED subscription to use a linked recurring credit with an allocation per seat. + * `seat_config` must be provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode(quantityManagementMode: JsonField) = + apply { + this.quantityManagementMode = quantityManagementMode + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - return other is Discounted && value == other.value - } + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } - override fun hashCode() = value.hashCode() + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) - override fun toString() = value.toString() + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is ApplicableSpendSpecifier && - sources == other.sources && - spendType == other.spendType && - discounted == other.discounted && - additionalProperties == other.additionalProperties + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private val hashCode: Int by lazy { - Objects.hash(sources, spendType, discounted, additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun toString() = - "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Subscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("subscriptionRate", subscriptionRate), + id, + billingCycleConfig, + customFields, + description, + duration, + fiatCreditTypeId, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + additionalProperties.toMutableMap(), + ) } - class ResetFrequency + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + collectionSchedule().validate() + proration().validate() + subscriptionRate().validate() + id() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + duration().ifPresent { it.validate() } + fiatCreditTypeId() + initialQuantity() + name() + quantityManagementMode().ifPresent { it.validate() } + seatConfig().ifPresent { it.validate() } + startingAtOffset().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + + (if (initialQuantity.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + class CollectionSchedule @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -21692,30 +24235,36 @@ private constructor( companion object { - @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + @JvmField val ADVANCE = of("ADVANCE") - @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - /** An enum containing [ResetFrequency]'s known values. */ + /** An enum containing [CollectionSchedule]'s known values. */ enum class Known { - BILLING_PERIOD + ADVANCE, + ARREARS, } /** - * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILLING_PERIOD, + ADVANCE, + ARREARS, /** - * An enum member indicating that [ResetFrequency] was instantiated with an unknown - * value. + * An enum member indicating that [CollectionSchedule] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -21729,7 +24278,8 @@ private constructor( */ fun value(): Value = when (this) { - BILLING_PERIOD -> Value.BILLING_PERIOD + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS else -> Value._UNKNOWN } @@ -21744,8 +24294,10 @@ private constructor( */ fun known(): Known = when (this) { - BILLING_PERIOD -> Known.BILLING_PERIOD - else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") } /** @@ -21774,7 +24326,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ResetFrequency = apply { + fun validate(): CollectionSchedule = apply { if (validated) { return@apply } @@ -21804,7 +24356,7 @@ private constructor( return true } - return other is ResetFrequency && value == other.value + return other is CollectionSchedule && value == other.value } override fun hashCode() = value.hashCode() @@ -21812,871 +24364,851 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpendTracker && - alias == other.alias && - applicableSpendSpecifiers == other.applicableSpendSpecifiers && - creditTypeId == other.creditTypeId && - resetFrequency == other.resetFrequency && - additionalProperties == other.additionalProperties - } + class Proration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash( - alias, - applicableSpendSpecifiers, - creditTypeId, - resetFrequency, - additionalProperties, - ) - } + @JsonCreator + private constructor( + @JsonProperty("invoice_behavior") + @ExcludeMissing + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) - override fun hashCode(): Int = hashCode + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun invoiceBehavior(): InvoiceBehavior = invoiceBehavior.getRequired("invoice_behavior") - override fun toString() = - "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - class Subscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val subscriptionRate: JsonField, - private val id: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val duration: JsonField, - private val fiatCreditTypeId: JsonField, - private val initialQuantity: JsonField, - private val name: JsonField, - private val quantityManagementMode: JsonField, - private val seatConfig: JsonField, - private val startingAtOffset: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") - @JsonCreator - private constructor( - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fiatCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("initial_quantity") + /** + * Returns the raw JSON value of [invoiceBehavior]. + * + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_behavior") @ExcludeMissing - initialQuantity: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") + fun _invoiceBehavior(): JsonField = invoiceBehavior + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_prorated") @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") + fun _isProrated(): JsonField = isProrated + + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rounding") @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") + fun _rounding(): JsonField = rounding + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - ) : this( - collectionSchedule, - proration, - subscriptionRate, - id, - customFields, - description, - duration, - fiatCreditTypeId, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - mutableMapOf(), - ) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun proration(): Proration = proration.getRequired("proration") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") + /** + * Returns a mutable builder for constructing an instance of [Proration]. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + /** A builder for [Proration]. */ + class Builder internal constructor() { - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + private var invoiceBehavior: JsonField? = null + private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + @JvmSynthetic + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() + } + + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) + + /** + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } + + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fiatCreditTypeId(): Optional = - fiatCreditTypeId.getOptional("fiat_credit_type_id") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a SEAT_BASED - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantityManagementMode(): Optional = - quantityManagementMode.getOptional("quantity_management_mode") + /** + * Returns an immutable instance of [Proration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Proration = + Proration( + checkRequired("invoiceBehavior", invoiceBehavior), + checkRequired("isProrated", isProrated), + rounding, + additionalProperties.toMutableMap(), + ) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + private var validated: Boolean = false - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startingAtOffset(): Optional = - startingAtOffset.getOptional("starting_at_offset") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + invoiceBehavior().validate() + isProrated() + rounding().ifPresent { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + companion object { - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") - /** - * Returns the raw JSON value of [fiatCreditTypeId]. - * - * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId + @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") - /** - * Returns the raw JSON value of [initialQuantity]. - * - * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("initial_quantity") - @ExcludeMissing - fun _initialQuantity(): JsonField = initialQuantity + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = quantityManagementMode + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - companion object { + known() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [Subscription]. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** A builder for [Subscription]. */ - class Builder internal constructor() { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var subscriptionRate: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var fiatCreditTypeId: JsonField = JsonMissing.of() - private var initialQuantity: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantityManagementMode: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var startingAtOffset: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - collectionSchedule = subscription.collectionSchedule - proration = subscription.proration - subscriptionRate = subscription.subscriptionRate - id = subscription.id - customFields = subscription.customFields - description = subscription.description - duration = subscription.duration - fiatCreditTypeId = subscription.fiatCreditTypeId - initialQuantity = subscription.initialQuantity - name = subscription.name - quantityManagementMode = subscription.quantityManagementMode - seatConfig = subscription.seatConfig - startingAtOffset = subscription.startingAtOffset - additionalProperties = subscription.additionalProperties.toMutableMap() - } + return other is InvoiceBehavior && value == other.value + } - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule + override fun toString() = value.toString() } - fun proration(proration: Proration) = proration(JsonField.of(proration)) + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit. For USD, this means rounding to the nearest dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - fun id(id: String) = id(JsonField.of(id)) + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun description(description: String) = description(JsonField.of(description)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun duration(duration: Duration) = duration(JsonField.of(duration)) + /** A builder for [Rounding]. */ + class Builder internal constructor() { - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun fiatCreditTypeId(fiatCreditTypeId: String) = - fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { - this.fiatCreditTypeId = fiatCreditTypeId - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - fun initialQuantity(initialQuantity: Double) = - initialQuantity(JsonField.of(initialQuantity)) + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Sets [Builder.initialQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.initialQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun initialQuantity(initialQuantity: JsonField) = apply { - this.initialQuantity = initialQuantity - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * SEAT_BASED subscription to use a linked recurring credit with an allocation per seat. - * `seat_config` must be provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode(quantityManagementMode: JsonField) = - apply { - this.quantityManagementMode = quantityManagementMode - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset - } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns an immutable instance of [Subscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Subscription = - Subscription( - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("subscriptionRate", subscriptionRate), - id, - customFields, - description, - duration, - fiatCreditTypeId, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Subscription = apply { - if (validated) { - return@apply - } + @JvmField val HALF_UP = of("HALF_UP") - collectionSchedule().validate() - proration().validate() - subscriptionRate().validate() - id() - customFields().ifPresent { it.validate() } - description() - duration().ifPresent { it.validate() } - fiatCreditTypeId() - initialQuantity() - name() - quantityManagementMode().ifPresent { it.validate() } - seatConfig().ifPresent { it.validate() } - startingAtOffset().ifPresent { it.validate() } - validated = true - } + @JvmField val FLOOR = of("FLOOR") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + - (if (initialQuantity.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - class CollectionSchedule - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - @JvmField val ADVANCE = of("ADVANCE") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmField val ARREARS = of("ARREARS") + private var validated: Boolean = false - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } + known() + validated = true + } - /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + return other is RoundingMethod && value == other.value + } - private var validated: Boolean = false + override fun hashCode() = value.hashCode() - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply + override fun toString() = value.toString() } - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CollectionSchedule && value == other.value + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" } - class Proration + class SubscriptionRate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val billingFrequency: JsonField, + private val product: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + product: JsonField = JsonMissing.of(), + ) : this(billingFrequency, product, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun invoiceBehavior(): InvoiceBehavior = invoiceBehavior.getRequired("invoice_behavior") + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + fun product(): Product = product.getRequired("product") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [billingFrequency]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _billingFrequency(): JsonField = billingFrequency /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [product]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22693,57 +25225,55 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Proration]. + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .billingFrequency() + * .product() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [SubscriptionRate]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField? = null - private var isProrated: JsonField? = null + private var billingFrequency: JsonField? = null + private var product: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + product = subscriptionRate.product + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() } - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the field + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency } - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + fun product(product: Product) = product(JsonField.of(product)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.product] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * You should usually call [Builder.product] with a well-typed [Product] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + fun product(product: JsonField) = apply { this.product = product } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -22768,22 +25298,22 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [SubscriptionRate]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .billingFrequency() + * .product() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration( - checkRequired("invoiceBehavior", invoiceBehavior), - checkRequired("isProrated", isProrated), + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("product", product), additionalProperties.toMutableMap(), ) } @@ -22800,13 +25330,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - invoiceBehavior().validate() - isProrated() + billingFrequency().validate() + product().validate() validated = true } @@ -22826,10 +25356,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) - class InvoiceBehavior + class BillingFrequency @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22843,87 +25373,297 @@ private constructor( */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - companion object { + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + } + + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } + + /** + * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [BillingFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BillingFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + fun toBuilder() = Builder().from(this) - @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + companion object { - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [InvoiceBehavior]'s known values. */ - enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - } + /** A builder for [Product]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) - /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an - * unknown value. + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE - else -> Value._UNKNOWN + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE - else -> - throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -22936,12 +25676,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): InvoiceBehavior = apply { + fun validate(): Product = apply { if (validated) { return@apply } - known() + id() + name() validated = true } @@ -22959,19 +25700,28 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is InvoiceBehavior && value == other.value + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -22979,71 +25729,52 @@ private constructor( return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + product == other.product && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(billingFrequency, product, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" } - class SubscriptionRate + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val billingFrequency: JsonField, - private val product: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product") + @JsonProperty("invoice_placement") @ExcludeMissing - product: JsonField = JsonMissing.of(), - ) : this(billingFrequency, product, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + invoicePlacement: JsonField = JsonMissing.of() + ) : this(invoicePlacement, mutableMapOf()) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun product(): Product = product.getRequired("product") + fun invoicePlacement(): Optional = + invoicePlacement.getOptional("invoice_placement") /** - * Returns the raw JSON value of [billingFrequency]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("billing_frequency") + @JsonProperty("invoice_placement") @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency - - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23060,56 +25791,37 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` + * Returns a mutable builder for constructing an instance of [BillingCycleConfig]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionRate]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var billingFrequency: JsonField? = null - private var product: JsonField? = null + private var invoicePlacement: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - product = subscriptionRate.product - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() } - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the field + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement } - fun product(product: Product) = product(JsonField.of(product)) - - /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun product(product: JsonField) = apply { this.product = product } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23133,24 +25845,12 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionRate]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("product", product), - additionalProperties.toMutableMap(), - ) + fun build(): BillingCycleConfig = + BillingCycleConfig(invoicePlacement, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -23165,13 +25865,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): SubscriptionRate = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - billingFrequency().validate() - product().validate() + invoicePlacement().ifPresent { it.validate() } validated = true } @@ -23190,11 +25889,9 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + internal fun validity(): Int = (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) - class BillingFrequency + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23210,30 +25907,24 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [BillingFrequency]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [BillingFrequency] can contain an unknown value in a couple of + * An instance of [InvoicePlacement] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -23241,12 +25932,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [BillingFrequency] was instantiated with an + * An enum member indicating that [InvoicePlacement] was instantiated with an * unknown value. */ _UNKNOWN, @@ -23261,10 +25950,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -23279,12 +25966,10 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE else -> - throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") } /** @@ -23313,7 +25998,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): BillingFrequency = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -23343,7 +26028,7 @@ private constructor( return true } - return other is BillingFrequency && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -23351,233 +26036,24 @@ private constructor( override fun toString() = value.toString() } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Product]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - product == other.product && + return other is BillingCycleConfig && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(billingFrequency, product, additionalProperties) + Objects.hash(invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + "BillingCycleConfig{invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -24769,6 +27245,7 @@ private constructor( proration == other.proration && subscriptionRate == other.subscriptionRate && id == other.id && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && duration == other.duration && @@ -24787,6 +27264,7 @@ private constructor( proration, subscriptionRate, id, + billingCycleConfig, customFields, description, duration, @@ -24803,7 +27281,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, duration=$duration, fiatCreditTypeId=$fiatCreditTypeId, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, additionalProperties=$additionalProperties}" + "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, duration=$duration, fiatCreditTypeId=$fiatCreditTypeId, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponse.kt index e06df0c8..623f0208 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponse.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponse.kt @@ -5820,6 +5820,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditTemplateIds: JsonField>, private val billingFrequency: JsonField, private val commitTemplateIds: JsonField>, private val presentationGroupValues: JsonField, @@ -5832,6 +5833,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_template_ids") + @ExcludeMissing + anyCommitOrCreditTemplateIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -5854,6 +5858,7 @@ private constructor( @ExcludeMissing recurringCommitTemplateIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditTemplateIds, billingFrequency, commitTemplateIds, presentationGroupValues, @@ -5864,6 +5869,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun anyCommitOrCreditTemplateIds(): Optional> = + anyCommitOrCreditTemplateIds.getOptional("any_commit_or_credit_template_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -5911,6 +5923,17 @@ private constructor( fun recurringCommitTemplateIds(): Optional> = recurringCommitTemplateIds.getOptional("recurring_commit_template_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditTemplateIds]. + * + * Unlike [anyCommitOrCreditTemplateIds], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("any_commit_or_credit_template_ids") + @ExcludeMissing + fun _anyCommitOrCreditTemplateIds(): JsonField> = + anyCommitOrCreditTemplateIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -6007,6 +6030,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditTemplateIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitTemplateIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -6019,6 +6043,10 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditTemplateIds = + overrideSpecifier.anyCommitOrCreditTemplateIds.map { + it.toMutableList() + } billingFrequency = overrideSpecifier.billingFrequency commitTemplateIds = overrideSpecifier.commitTemplateIds.map { it.toMutableList() } @@ -6031,6 +6059,38 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditTemplateIds(anyCommitOrCreditTemplateIds: List) = + anyCommitOrCreditTemplateIds(JsonField.of(anyCommitOrCreditTemplateIds)) + + /** + * Sets [Builder.anyCommitOrCreditTemplateIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditTemplateIds] with a + * well-typed `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun anyCommitOrCreditTemplateIds( + anyCommitOrCreditTemplateIds: JsonField> + ) = apply { + this.anyCommitOrCreditTemplateIds = + anyCommitOrCreditTemplateIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditTemplateIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditTemplateId(anyCommitOrCreditTemplateId: String) = + apply { + anyCommitOrCreditTemplateIds = + (anyCommitOrCreditTemplateIds ?: JsonField.of(mutableListOf())) + .also { + checkKnown("anyCommitOrCreditTemplateIds", it) + .add(anyCommitOrCreditTemplateId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -6198,6 +6258,9 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditTemplateIds ?: JsonMissing.of()).map { + it.toImmutable() + }, billingFrequency, (commitTemplateIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -6228,6 +6291,7 @@ private constructor( return@apply } + anyCommitOrCreditTemplateIds() billingFrequency().ifPresent { it.validate() } commitTemplateIds() presentationGroupValues().ifPresent { it.validate() } @@ -6254,7 +6318,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditTemplateIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitTemplateIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -6674,6 +6739,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditTemplateIds == other.anyCommitOrCreditTemplateIds && billingFrequency == other.billingFrequency && commitTemplateIds == other.commitTemplateIds && presentationGroupValues == other.presentationGroupValues && @@ -6686,6 +6752,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditTemplateIds, billingFrequency, commitTemplateIds, presentationGroupValues, @@ -6700,7 +6767,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitTemplateIds=$commitTemplateIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitTemplateIds=$recurringCommitTemplateIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditTemplateIds=$anyCommitOrCreditTemplateIds, billingFrequency=$billingFrequency, commitTemplateIds=$commitTemplateIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitTemplateIds=$recurringCommitTemplateIds, additionalProperties=$additionalProperties}" } class StartingAtOffset @@ -13619,6 +13686,7 @@ private constructor( private val invoiceAmount: JsonField, private val name: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -13666,6 +13734,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -13693,6 +13764,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -13816,6 +13888,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -13987,6 +14068,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -14075,6 +14166,7 @@ private constructor( private var invoiceAmount: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -14099,6 +14191,7 @@ private constructor( invoiceAmount = recurringCommit.invoiceAmount name = recurringCommit.name proration = recurringCommit.proration + prorationRounding = recurringCommit.prorationRounding recurrenceFrequency = recurringCommit.recurrenceFrequency rolloverFraction = recurringCommit.rolloverFraction specifiers = recurringCommit.specifiers.map { it.toMutableList() } @@ -14324,6 +14417,28 @@ private constructor( this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - * The commits will be created on the usage invoice frequency. If provided: - The @@ -14467,6 +14582,7 @@ private constructor( invoiceAmount, name, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -14506,6 +14622,7 @@ private constructor( invoiceAmount().ifPresent { it.validate() } name() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -14543,6 +14660,7 @@ private constructor( (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -16670,121 +16788,143 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected + * type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -16797,12 +16937,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -16820,510 +16961,535 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - return other is RecurrenceFrequency && value == other.value - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode() = value.hashCode() + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun toString() = value.toString() - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val allocation: JsonField, - private val applySeatIncreaseConfig: JsonField, - private val subscriptionTemplateId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - @JsonCreator - private constructor( - @JsonProperty("allocation") + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - @JsonProperty("apply_seat_increase_config") + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_template_id") + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - subscriptionTemplateId: JsonField = JsonMissing.of(), - ) : this( - allocation, - applySeatIncreaseConfig, - subscriptionTemplateId, - mutableMapOf(), - ) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun allocation(): Allocation = allocation.getRequired("allocation") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun subscriptionTemplateId(): String = - subscriptionTemplateId.getRequired("subscription_template_id") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [subscriptionTemplateId]. - * - * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("subscription_template_id") - @ExcludeMissing - fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - fun toBuilder() = Builder().from(this) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - companion object { + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Returns a mutable builder for constructing an instance of - * [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var allocation: JsonField? = null - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionTemplateId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - allocation = subscriptionConfig.allocation - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId - additionalProperties = - subscriptionConfig.additionalProperties.toMutableMap() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + private var validated: Boolean = false /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - fun subscriptionTemplateId(subscriptionTemplateId: String) = - subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionTemplateId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { - this.subscriptionTemplateId = subscriptionTemplateId - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val HALF_UP = of("HALF_UP") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("allocation", allocation), - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionTemplateId", subscriptionTemplateId), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - allocation().validate() - applySeatIncreaseConfig().validate() - subscriptionTemplateId() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (allocation.asKnown().getOrNull()?.validity() ?: 0) + - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) + known() + validated = true + } - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + return other is RoundingMethod && value == other.value + } - @JvmField val POOLED = of("POOLED") + override fun hashCode() = value.hashCode() - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + override fun toString() = value.toString() } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - INDIVIDUAL, - POOLED, + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Allocation] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - POOLED, - /** - * An enum member indicating that [Allocation] was instantiated with an - * unknown value. - */ - _UNKNOWN, + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED - else -> Value._UNKNOWN - } + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> - throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [decimalPlaces]. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Returns the raw JSON value of [roundingMethod]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun validate(): Allocation = apply { - if (validated) { - return@apply - } + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - known() - validated = true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allocation && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) - - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. + * Returns a mutable builder for constructing an instance of [Invoice]. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ApplySeatIncreaseConfig]. */ + /** A builder for [Invoice]. */ class Builder internal constructor() { - private var isProrated: JsonField? = null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() - } + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = @@ -17349,20 +17515,22 @@ private constructor( } /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -17379,12 +17547,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): ApplySeatIncreaseConfig = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - isProrated() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -17403,26 +17572,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(isProrated, additionalProperties) + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -17430,1059 +17757,2474 @@ private constructor( return true } - return other is SubscriptionConfig && - allocation == other.allocation && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionTemplateId == other.subscriptionTemplateId && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - allocation, - applySeatIncreaseConfig, - subscriptionTemplateId, - additionalProperties, - ) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is RecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAtOffset == other.startingAtOffset && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - duration == other.duration && - invoiceAmount == other.invoiceAmount && - name == other.name && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - invoiceAmount, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val MONTHLY = of("MONTHLY") - override fun toString() = - "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } + @JvmField val QUARTERLY = of("QUARTERLY") - class RecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val product: JsonField, - private val rateType: JsonField, - private val startingAtOffset: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val duration: JsonField, - private val name: JsonField, - private val proration: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val ANNUAL = of("ANNUAL") - @JsonCreator + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") + private val allocation: JsonField, + private val applySeatIncreaseConfig: JsonField, + private val subscriptionTemplateId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_template_id") + @ExcludeMissing + subscriptionTemplateId: JsonField = JsonMissing.of(), + ) : this( + allocation, + applySeatIncreaseConfig, + subscriptionTemplateId, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): Allocation = allocation.getRequired("allocation") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun subscriptionTemplateId(): String = + subscriptionTemplateId.getRequired("subscription_template_id") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product") + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [applySeatIncreaseConfig]. + * + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("apply_seat_increase_config") @ExcludeMissing - product: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") - @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") - @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig + + /** + * Returns the raw JSON value of [subscriptionTemplateId]. + * + * Unlike [subscriptionTemplateId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("subscription_template_id") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") + fun _subscriptionTemplateId(): JsonField = subscriptionTemplateId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - subscriptionConfig: JsonField = JsonMissing.of(), - ) : this( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - mutableMapOf(), - ) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionTemplateId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + allocation = subscriptionConfig.allocation + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId + additionalProperties = + subscriptionConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + + fun subscriptionTemplateId(subscriptionTemplateId: String) = + subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + + /** + * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTemplateId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { + this.subscriptionTemplateId = subscriptionTemplateId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("allocation", allocation), + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionTemplateId", subscriptionTemplateId), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + allocation().validate() + applySeatIncreaseConfig().validate() + subscriptionTemplateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) + + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmField val POOLED = of("POOLED") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } + + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } + + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Allocation] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> + throw MetronomeInvalidDataException("Unknown Allocation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allocation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) + + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + @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 + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { + + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } + + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } + + isProrated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isProrated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionConfig && + allocation == other.allocation && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionTemplateId == other.subscriptionTemplateId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocation, + applySeatIncreaseConfig, + subscriptionTemplateId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAtOffset == other.startingAtOffset && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + duration == other.duration && + invoiceAmount == other.invoiceAmount && + name == other.name && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + invoiceAmount, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, invoiceAmount=$invoiceAmount, name=$name, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } + + class RecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val product: JsonField, + private val rateType: JsonField, + private val startingAtOffset: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val duration: JsonField, + private val name: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") + @ExcludeMissing + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = JsonMissing.of(), + ) : this( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + + /** + * The amount of time each of the created commits will be valid for + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priority(): Double = priority.getRequired("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun product(): Product = product.getRequired("product") + + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun rateType(): RateType = rateType.getRequired("rate_type") + + /** + * Offset relative to the contract start date that determines the start time for the + * first commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startingAtOffset(): StartingAtOffset = + startingAtOffset.getRequired("starting_at_offset") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Offset relative to the recurring credit start that determines when the contract will + * stop creating recurring commits. optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") + + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be between + * 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = specifiers.getOptional("specifiers") + + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount + + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType + + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration + + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency + + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = subscriptionConfig + + @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 [RecurringCredit]. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAtOffset() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecurringCredit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var product: JsonField? = null + private var rateType: JsonField? = null + private var startingAtOffset: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recurringCredit: RecurringCredit) = apply { + id = recurringCredit.id + accessAmount = recurringCredit.accessAmount + commitDuration = recurringCredit.commitDuration + priority = recurringCredit.priority + product = recurringCredit.product + rateType = recurringCredit.rateType + startingAtOffset = recurringCredit.startingAtOffset + applicableProductIds = + recurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + recurringCredit.applicableProductTags.map { it.toMutableList() } + description = recurringCredit.description + duration = recurringCredit.duration + name = recurringCredit.name + proration = recurringCredit.proration + prorationRounding = recurringCredit.prorationRounding + recurrenceFrequency = recurringCredit.recurrenceFrequency + rolloverFraction = recurringCredit.rolloverFraction + specifiers = recurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = recurringCredit.subscriptionConfig + additionalProperties = recurringCredit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = + accessAmount(JsonField.of(accessAmount)) + + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } + + /** The amount of time each of the created commits will be valid for */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) + + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed + * [CommitDuration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } + + fun priority(priority: Double) = priority(JsonField.of(priority)) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + fun product(product: Product) = product(JsonField.of(product)) + + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun product(product: JsonField) = apply { this.product = product } + + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + /** + * Offset relative to the contract start date that determines the start time for the + * first commit + */ + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) + + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset + } + + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Offset relative to the recurring credit start that determines when the contract + * will stop creating recurring commits. optional + */ + fun duration(duration: Duration) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Determines whether the first and last commit will be prorated. If not provided, + * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) + + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun proration(proration: JsonField) = apply { + this.proration = proration + } + + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) + + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = + apply { + this.recurrenceFrequency = recurrenceFrequency + } + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be + * between 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. + */ + fun specifiers(specifiers: List) = + specifiers(JsonField.of(specifiers)) + + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifier] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifier) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [SubscriptionConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun subscriptionConfig(subscriptionConfig: JsonField) = apply { + this.subscriptionConfig = subscriptionConfig + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAtOffset() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringCredit = + RecurringCredit( + checkRequired("id", id), + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("product", product), + checkRequired("rateType", rateType), + checkRequired("startingAtOffset", startingAtOffset), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + additionalProperties.toMutableMap(), + ) + } - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + private var validated: Boolean = false /** - * The amount of time each of the created commits will be valid for + * Validates that the types of all values in this object match their expected types + * recursively. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun priority(): Double = priority.getRequired("priority") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun product(): Product = product.getRequired("product") - - /** - * Whether the created commits will use the commit rate or list rate + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun rateType(): RateType = rateType.getRequired("rate_type") + fun validate(): RecurringCredit = apply { + if (validated) { + return@apply + } - /** - * Offset relative to the contract start date that determines the start time for the - * first commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun startingAtOffset(): StartingAtOffset = - startingAtOffset.getRequired("starting_at_offset") + id() + accessAmount().validate() + commitDuration().validate() + priority() + product().validate() + rateType().validate() + startingAtOffset().validate() + applicableProductIds() + applicableProductTags() + description() + duration().ifPresent { it.validate() } + name() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + validated = true + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Will be passed down to the individual commits + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Used for best match union deserialization. */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Offset relative to the recurring credit start that determines when the contract will - * stop creating recurring commits. optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun proration(): Optional = proration.getOptional("proration") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be between - * 0 and 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun specifiers(): Optional> = specifiers.getOptional("specifiers") + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Attach a subscription to the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + companion object { - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + /** + * Returns a mutable builder for constructing an instance of [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun creditTypeId(creditTypeId: String) = + creditTypeId(JsonField.of(creditTypeId)) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - /** - * Returns the raw JSON value of [recurrenceFrequency]. - * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recurrence_frequency") - @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") - @ExcludeMissing - fun _subscriptionConfig(): JsonField = subscriptionConfig + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [RecurringCredit]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAtOffset() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecurringCredit]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var product: JsonField? = null - private var rateType: JsonField? = null - private var startingAtOffset: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(recurringCredit: RecurringCredit) = apply { - id = recurringCredit.id - accessAmount = recurringCredit.accessAmount - commitDuration = recurringCredit.commitDuration - priority = recurringCredit.priority - product = recurringCredit.product - rateType = recurringCredit.rateType - startingAtOffset = recurringCredit.startingAtOffset - applicableProductIds = - recurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - recurringCredit.applicableProductTags.map { it.toMutableList() } - description = recurringCredit.description - duration = recurringCredit.duration - name = recurringCredit.name - proration = recurringCredit.proration - recurrenceFrequency = recurringCredit.recurrenceFrequency - rolloverFraction = recurringCredit.rolloverFraction - specifiers = recurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = recurringCredit.subscriptionConfig - additionalProperties = recurringCredit.additionalProperties.toMutableMap() + creditTypeId() + unitPrice() + quantity() + validated = true } - fun id(id: String) = id(JsonField.of(id)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.id] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun id(id: JsonField) = apply { this.id = id } + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = - accessAmount(JsonField.of(accessAmount)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties } - /** The amount of time each of the created commits will be valid for */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) - - /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.commitDuration] with a well-typed - * [CommitDuration] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) } - fun priority(priority: Double) = priority(JsonField.of(priority)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } - fun product(product: Product) = product(JsonField.of(product)) + /** The amount of time each of the created commits will be valid for */ + class CommitDuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val unit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun product(product: JsonField) = apply { this.product = product } - - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + fun value(): Double = value.getRequired("value") /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + fun unit(): Optional = unit.getOptional("unit") /** - * Offset relative to the contract start date that determines the start time for the - * first commit + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * Returns the raw JSON value of [unit]. * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @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 [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** Will be passed down to the individual commits */ - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - } - /** Will be passed down to the individual commits */ - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + additionalProperties.toMutableMap(), + ) } - fun description(description: String) = description(JsonField.of(description)) + private var validated: Boolean = false /** - * Sets [Builder.description] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun description(description: JsonField) = apply { - this.description = description + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } + + value() + unit().ifPresent { it.validate() } + validated = true } - /** - * Offset relative to the recurring credit start that determines when the contract - * will stop creating recurring commits. optional - */ - fun duration(duration: Duration) = duration(JsonField.of(duration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.duration] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Used for best match union deserialization. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) - fun name(name: String) = name(JsonField.of(name)) + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Determines whether the first and last commit will be prorated. If not provided, - * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + companion object { - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun proration(proration: JsonField) = apply { - this.proration = proration - } + @JvmField val PERIODS = of("PERIODS") - /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } - /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = - apply { - this.recurrenceFrequency = recurrenceFrequency + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS } - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be - * between 0 and 1. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - */ - fun specifiers(specifiers: List) = - specifiers(JsonField.of(specifiers)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + private var validated: Boolean = false - /** - * Adds a single [CommitSpecifier] to [specifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifier) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply } - } - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + known() + validated = true + } - /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [SubscriptionConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun subscriptionConfig(subscriptionConfig: JsonField) = apply { - this.subscriptionConfig = subscriptionConfig - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + return other is Unit && value == other.value } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun hashCode() = value.hashCode() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun toString() = value.toString() } - /** - * Returns an immutable instance of [RecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAtOffset() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RecurringCredit = - RecurringCredit( - checkRequired("id", id), - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("product", product), - checkRequired("rateType", rateType), - checkRequired("startingAtOffset", startingAtOffset), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RecurringCredit = apply { - if (validated) { - return@apply + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties } - id() - accessAmount().validate() - commitDuration().validate() - priority() - product().validate() - rateType().validate() - startingAtOffset().validate() - applicableProductIds() - applicableProductTags() - description() - duration().ifPresent { it.validate() } - name() - proration().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(value, unit, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + override fun hashCode(): Int = hashCode - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + fun id(): String = id.getRequired("id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [id]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [quantity]. + * Returns the raw JSON value of [name]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * Unlike [name], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -18499,70 +20241,52 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AccessAmount]. + * Returns a mutable builder for constructing an instance of [Product]. * * The following fields are required: * ```java - * .creditTypeId() - * .unitPrice() + * .id() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AccessAmount]. */ + /** A builder for [Product]. */ class Builder internal constructor() { - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } - - fun creditTypeId(creditTypeId: String) = - creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * You should usually call [Builder.id] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + fun id(id: JsonField) = apply { this.id = id } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.quantity] with a well-typed [Double] value + * You should usually call [Builder.name] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -18587,23 +20311,22 @@ private constructor( } /** - * Returns an immutable instance of [AccessAmount]. + * Returns an immutable instance of [Product]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .creditTypeId() - * .unitPrice() + * .id() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -18620,14 +20343,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): AccessAmount = apply { + fun validate(): Product = apply { if (validated) { return@apply } - creditTypeId() - unitPrice() - quantity() + id() + name() validated = true } @@ -18647,181 +20369,120 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && + return other is Product && + id == other.id && + name == other.name && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" } - /** The amount of time each of the created commits will be valid for */ - class CommitDuration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val value: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun value(): Double = value.getRequired("value") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns the raw JSON value of [unit]. + * Returns this class instance's raw value. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - - @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) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** - * Returns a mutable builder for constructing an instance of [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CommitDuration]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() - } + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - fun value(value: Double) = value(JsonField.of(value)) + @JvmField val LIST_RATE = of("LIST_RATE") - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - fun unit(unit: Unit) = unit(JsonField.of(unit)) + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An enum member indicating that [RateType] was instantiated with an unknown + * value. */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [CommitDuration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false /** @@ -18834,13 +20495,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): CommitDuration = apply { + fun validate(): RateType = apply { if (validated) { return@apply } - value() - unit().ifPresent { it.validate() } + known() validated = true } @@ -18858,211 +20518,68 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) - - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERIODS = of("PERIODS") - - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } - - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } - - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, - /** - * An enum member indicating that [Unit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Unit && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(value, unit, additionalProperties) + return other is RateType && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Product + /** + * Offset relative to the contract start date that determines the start time for the + * first commit + */ + class StartingAtOffset @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val name: JsonField, + private val unit: JsonField, + private val value: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(unit, value, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") + fun unit(): Unit = unit.getRequired("unit") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun name(): String = name.getRequired("name") + fun value(): Long = value.getRequired("value") /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [unit]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [value]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * Unlike [value], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19079,52 +20596,52 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Product]. + * Returns a mutable builder for constructing an instance of [StartingAtOffset]. * * The following fields are required: * ```java - * .id() - * .name() + * .unit() + * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Product]. */ + /** A builder for [StartingAtOffset]. */ class Builder internal constructor() { - private var id: JsonField? = null - private var name: JsonField? = null + private var unit: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() + internal fun from(startingAtOffset: StartingAtOffset) = apply { + unit = startingAtOffset.unit + value = startingAtOffset.value + additionalProperties = startingAtOffset.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun unit(unit: Unit) = unit(JsonField.of(unit)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.unit] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value + * You should usually call [Builder.unit] with a well-typed [Unit] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun unit(unit: JsonField) = apply { this.unit = unit } - fun name(name: String) = name(JsonField.of(name)) + fun value(value: Long) = value(JsonField.of(value)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.value] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value + * You should usually call [Builder.value] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -19149,22 +20666,22 @@ private constructor( } /** - * Returns an immutable instance of [Product]. + * Returns an immutable instance of [StartingAtOffset]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() - * .name() + * .unit() + * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), + fun build(): StartingAtOffset = + StartingAtOffset( + checkRequired("unit", unit), + checkRequired("value", value), additionalProperties.toMutableMap(), ) } @@ -19181,13 +20698,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Product = apply { + fun validate(): StartingAtOffset = apply { if (validated) { return@apply } - id() - name() + unit().validate() + value() validated = true } @@ -19207,175 +20724,190 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + @JvmField val DAYS = of("DAYS") - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField val WEEKS = of("WEEKS") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmField val MONTHS = of("MONTHS") - companion object { + @JvmField val YEARS = of("YEARS") - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } - @JvmField val LIST_RATE = of("LIST_RATE") + /** An enum containing [Unit]'s known values. */ + enum class Known { + DAYS, + WEEKS, + MONTHS, + YEARS, + } - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAYS, + WEEKS, + MONTHS, + YEARS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAYS -> Value.DAYS + WEEKS -> Value.WEEKS + MONTHS -> Value.MONTHS + YEARS -> Value.YEARS + else -> Value._UNKNOWN + } - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_RATE, - LIST_RATE, /** - * An enum member indicating that [RateType] was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. */ - _UNKNOWN, - } + fun known(): Known = + when (this) { + DAYS -> Known.DAYS + WEEKS -> Known.WEEKS + MONTHS -> Known.MONTHS + YEARS -> Known.YEARS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + private var validated: Boolean = false - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): RateType = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Unit && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is RateType && value == other.value + return other is StartingAtOffset && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(unit, value, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" } /** - * Offset relative to the contract start date that determines the start time for the - * first commit + * Offset relative to the recurring credit start that determines when the contract will + * stop creating recurring commits. optional */ - class StartingAtOffset + class Duration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unit: JsonField, @@ -19434,7 +20966,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [StartingAtOffset]. + * Returns a mutable builder for constructing an instance of [Duration]. * * The following fields are required: * ```java @@ -19445,7 +20977,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [StartingAtOffset]. */ + /** A builder for [Duration]. */ class Builder internal constructor() { private var unit: JsonField? = null @@ -19453,10 +20985,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(startingAtOffset: StartingAtOffset) = apply { - unit = startingAtOffset.unit - value = startingAtOffset.value - additionalProperties = startingAtOffset.additionalProperties.toMutableMap() + internal fun from(duration: Duration) = apply { + unit = duration.unit + value = duration.value + additionalProperties = duration.additionalProperties.toMutableMap() } fun unit(unit: Unit) = unit(JsonField.of(unit)) @@ -19504,7 +21036,7 @@ private constructor( } /** - * Returns an immutable instance of [StartingAtOffset]. + * Returns an immutable instance of [Duration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -19516,8 +21048,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): StartingAtOffset = - StartingAtOffset( + fun build(): Duration = + Duration( checkRequired("unit", unit), checkRequired("value", value), additionalProperties.toMutableMap(), @@ -19536,7 +21068,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): StartingAtOffset = apply { + fun validate(): Duration = apply { if (validated) { return@apply } @@ -19715,79 +21247,217 @@ private constructor( return other is Unit && value == other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Duration && + unit == other.unit && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unit, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false - override fun toString() = value.toString() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is StartingAtOffset && - unit == other.unit && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unit, value, additionalProperties) + return other is Proration && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "StartingAtOffset{unit=$unit, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Offset relative to the recurring credit start that determines when the contract will - * stop creating recurring commits. optional - */ - class Duration + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: JsonField, - private val value: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(unit, value, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unit(): Unit = unit.getRequired("unit") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun value(): Long = value.getRequired("value") + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [access]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * Unlike [access], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19804,52 +21474,34 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Duration]. - * - * The following fields are required: - * ```java - * .unit() - * .value() - * ``` + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Duration]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var unit: JsonField? = null - private var value: JsonField? = null + private var access: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(duration: Duration) = apply { - unit = duration.unit - value = duration.value - additionalProperties = duration.additionalProperties.toMutableMap() + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - fun unit(unit: Unit) = unit(JsonField.of(unit)) - - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - fun value(value: Long) = value(JsonField.of(value)) + fun access(access: Access) = access(JsonField.of(access)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.access] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Long] value + * You should usually call [Builder.access] with a well-typed [Access] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun access(access: JsonField) = apply { this.access = access } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -19874,24 +21526,12 @@ private constructor( } /** - * Returns an immutable instance of [Duration]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .unit() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Duration = - Duration( - checkRequired("unit", unit), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -19906,13 +21546,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Duration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - unit().validate() - value() + access().ifPresent { it.validate() } validated = true } @@ -19931,114 +21570,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Returns this class instance's raw value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - @JvmField val DAYS = of("DAYS") + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - @JvmField val WEEKS = of("WEEKS") + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - @JvmField val MONTHS = of("MONTHS") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val YEARS = of("YEARS") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [Unit]'s known values. */ - enum class Known { - DAYS, - WEEKS, - MONTHS, - YEARS, - } + companion object { - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAYS, - WEEKS, - MONTHS, - YEARS, /** - * An enum member indicating that [Unit] was instantiated with an unknown - * value. + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAYS -> Value.DAYS - WEEKS -> Value.WEEKS - MONTHS -> Value.MONTHS - YEARS -> Value.YEARS - else -> Value._UNKNOWN + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - DAYS -> Known.DAYS - WEEKS -> Known.WEEKS - MONTHS -> Known.MONTHS - YEARS -> Known.YEARS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -20051,12 +21760,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Unit = apply { + fun validate(): Access = apply { if (validated) { return@apply } - known() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -20075,197 +21785,202 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Unit && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Duration && - unit == other.unit && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(unit, value, additionalProperties) - } + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - override fun hashCode(): Int = hashCode + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun toString() = - "Duration{unit=$unit, value=$value, additionalProperties=$additionalProperties}" - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmField val HALF_UP = of("HALF_UP") - companion object { + @JvmField val FLOOR = of("FLOOR") - @JvmField val NONE = of("NONE") + @JvmField val CEILING = of("CEILING") - @JvmField val FIRST = of("FIRST") + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JvmField val LAST = of("LAST") + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + private var validated: Boolean = false - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + known() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Proration = apply { - if (validated) { - return@apply + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && value == other.value + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** @@ -20298,6 +22013,8 @@ private constructor( @JvmField val WEEKLY = of("WEEKLY") + @JvmField val DAILY = of("DAILY") + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } @@ -20307,6 +22024,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, } /** @@ -20325,6 +22043,7 @@ private constructor( QUARTERLY, ANNUAL, WEEKLY, + DAILY, /** * An enum member indicating that [RecurrenceFrequency] was instantiated with an * unknown value. @@ -20345,6 +22064,7 @@ private constructor( QUARTERLY -> Value.QUARTERLY ANNUAL -> Value.ANNUAL WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY else -> Value._UNKNOWN } @@ -20363,6 +22083,7 @@ private constructor( QUARTERLY -> Known.QUARTERLY ANNUAL -> Known.ANNUAL WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY else -> throw MetronomeInvalidDataException( "Unknown RecurrenceFrequency: $value" @@ -20525,1256 +22246,1848 @@ private constructor( fun _additionalProperties(): Map = Collections.unmodifiableMap(additionalProperties) - fun toBuilder() = Builder().from(this) + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionTemplateId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + allocation = subscriptionConfig.allocation + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId + additionalProperties = + subscriptionConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + + fun subscriptionTemplateId(subscriptionTemplateId: String) = + subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + + /** + * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTemplateId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { + this.subscriptionTemplateId = subscriptionTemplateId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .applySeatIncreaseConfig() + * .subscriptionTemplateId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("allocation", allocation), + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionTemplateId", subscriptionTemplateId), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + allocation().validate() + applySeatIncreaseConfig().validate() + subscriptionTemplateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) + + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmField val POOLED = of("POOLED") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } + + /** An enum containing [Allocation]'s known values. */ + enum class Known { + INDIVIDUAL, + POOLED, + } + + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Allocation] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INDIVIDUAL, + POOLED, + /** + * An enum member indicating that [Allocation] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INDIVIDUAL -> Value.INDIVIDUAL + POOLED -> Value.POOLED + else -> Value._UNKNOWN + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + POOLED -> Known.POOLED + else -> + throw MetronomeInvalidDataException("Unknown Allocation: $value") + } /** - * Returns a mutable builder for constructing an instance of - * [SubscriptionConfig]. + * Returns this class instance's primitive wire representation. * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - @JvmStatic fun builder() = Builder() - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var allocation: JsonField? = null - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionTemplateId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - allocation = subscriptionConfig.allocation - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionTemplateId = subscriptionConfig.subscriptionTemplateId - additionalProperties = - subscriptionConfig.additionalProperties.toMutableMap() + known() + validated = true } - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allocation && value == other.value } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Indicates whether a mid-period seat increase should be prorated. * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - - fun subscriptionTemplateId(subscriptionTemplateId: String) = - subscriptionTemplateId(JsonField.of(subscriptionTemplateId)) + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") /** - * Sets [Builder.subscriptionTemplateId] to an arbitrary JSON value. + * Returns the raw JSON value of [isProrated]. * - * You should usually call [Builder.subscriptionTemplateId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun subscriptionTemplateId(subscriptionTemplateId: JsonField) = apply { - this.subscriptionTemplateId = subscriptionTemplateId + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { + + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } + + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + additionalProperties.toMutableMap(), + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + isProrated() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .allocation() - * .applySeatIncreaseConfig() - * .subscriptionTemplateId() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("allocation", allocation), - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionTemplateId", subscriptionTemplateId), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties } - allocation().validate() - applySeatIncreaseConfig().validate() - subscriptionTemplateId() - validated = true + private val hashCode: Int by lazy { + Objects.hash(isProrated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (allocation.asKnown().getOrNull()?.validity() ?: 0) + - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionTemplateId.asKnown().isPresent) 1 else 0) - - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + return other is SubscriptionConfig && + allocation == other.allocation && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionTemplateId == other.subscriptionTemplateId && + additionalProperties == other.additionalProperties + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val hashCode: Int by lazy { + Objects.hash( + allocation, + applySeatIncreaseConfig, + subscriptionTemplateId, + additionalProperties, + ) + } - companion object { + override fun hashCode(): Int = hashCode - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + override fun toString() = + "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" + } - @JvmField val POOLED = of("POOLED") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + return other is RecurringCredit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAtOffset == other.startingAtOffset && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + duration == other.duration && + name == other.name && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - INDIVIDUAL, - POOLED, - } + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAtOffset, + applicableProductIds, + applicableProductTags, + description, + duration, + name, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Allocation] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - POOLED, - /** - * An enum member indicating that [Allocation] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + override fun hashCode(): Int = hashCode - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - POOLED -> Value.POOLED - else -> Value._UNKNOWN - } + override fun toString() = + "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - POOLED -> Known.POOLED - else -> - throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + /** + * Determines which scheduled and commit charges to consolidate onto the Contract's usage + * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for + * consolidation to occur. This field cannot be modified after a Contract has been created. + * If this field is omitted, charges will appear on a separate invoice from usage charges. + */ + class ScheduledChargesOnUsageInvoices + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply - } + @JvmField val ALL = of("ALL") - known() - validated = true - } + @JvmStatic + fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ + enum class Known { + ALL + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + /** + * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + else -> Value._UNKNOWN + } - return other is Allocation && value == other.value - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + else -> + throw MetronomeInvalidDataException( + "Unknown ScheduledChargesOnUsageInvoices: $value" + ) + } - override fun hashCode() = value.hashCode() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - override fun toString() = value.toString() + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ScheduledChargesOnUsageInvoices = apply { + if (validated) { + return@apply } - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { + known() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is ScheduledChargesOnUsageInvoices && value == other.value + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode() = value.hashCode() - fun toBuilder() = Builder().from(this) + override fun toString() = value.toString() + } - companion object { + class SpendTracker + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val alias: JsonField, + private val applicableSpendSpecifiers: JsonField>, + private val creditTypeId: JsonField, + private val resetFrequency: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JsonCreator + private constructor( + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + applicableSpendSpecifiers: JsonField> = + JsonMissing.of(), + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("reset_frequency") + @ExcludeMissing + resetFrequency: JsonField = JsonMissing.of(), + ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) - /** A builder for [ApplySeatIncreaseConfig]. */ - class Builder internal constructor() { + /** + * Human-readable identifier, unique per contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun alias(): String = alias.getRequired("alias") - private var isProrated: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun applicableSpendSpecifiers(): List = + applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") - @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") - /** - * Sets [Builder.isProrated] to an arbitrary JSON value. - * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [applicableSpendSpecifiers]. + * + * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + fun _applicableSpendSpecifiers(): JsonField> = + applicableSpendSpecifiers - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [resetFrequency]. + * + * Unlike [resetFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reset_frequency") + @ExcludeMissing + fun _resetFrequency(): JsonField = resetFrequency - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), - additionalProperties.toMutableMap(), - ) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): ApplySeatIncreaseConfig = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of [SpendTracker]. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - isProrated() - validated = true - } + /** A builder for [SpendTracker]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private var alias: JsonField? = null + private var applicableSpendSpecifiers: + JsonField>? = + null + private var creditTypeId: JsonField? = null + private var resetFrequency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun from(spendTracker: SpendTracker) = apply { + alias = spendTracker.alias + applicableSpendSpecifiers = + spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } + creditTypeId = spendTracker.creditTypeId + resetFrequency = spendTracker.resetFrequency + additionalProperties = spendTracker.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Human-readable identifier, unique per contract. */ + fun alias(alias: String) = alias(JsonField.of(alias)) - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } - private val hashCode: Int by lazy { - Objects.hash(isProrated, additionalProperties) - } + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: List + ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: JsonField> + ) = apply { + this.applicableSpendSpecifiers = + applicableSpendSpecifiers.map { it.toMutableList() } + } - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + /** + * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableSpendSpecifier( + applicableSpendSpecifier: ApplicableSpendSpecifier + ) = apply { + applicableSpendSpecifiers = + (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableSpendSpecifiers", it) + .add(applicableSpendSpecifier) + } } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } - return other is SubscriptionConfig && - allocation == other.allocation && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionTemplateId == other.subscriptionTemplateId && - additionalProperties == other.additionalProperties + fun resetFrequency(resetFrequency: ResetFrequency) = + resetFrequency(JsonField.of(resetFrequency)) + + /** + * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.resetFrequency] with a well-typed + * [ResetFrequency] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun resetFrequency(resetFrequency: JsonField) = apply { + this.resetFrequency = resetFrequency } - private val hashCode: Int by lazy { - Objects.hash( - allocation, - applySeatIncreaseConfig, - subscriptionTemplateId, - additionalProperties, - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun hashCode(): Int = hashCode + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = - "SubscriptionConfig{allocation=$allocation, applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionTemplateId=$subscriptionTemplateId, additionalProperties=$additionalProperties}" - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - return other is RecurringCredit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAtOffset == other.startingAtOffset && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - duration == other.duration && - name == other.name && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAtOffset, - applicableProductIds, - applicableProductTags, - description, - duration, - name, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) + /** + * Returns an immutable instance of [SpendTracker]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendTracker = + SpendTracker( + checkRequired("alias", alias), + checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { + it.toImmutable() + }, + checkRequired("creditTypeId", creditTypeId), + checkRequired("resetFrequency", resetFrequency), + additionalProperties.toMutableMap(), + ) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "RecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAtOffset=$startingAtOffset, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, duration=$duration, name=$name, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } - - /** - * Determines which scheduled and commit charges to consolidate onto the Contract's usage - * invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for - * consolidation to occur. This field cannot be modified after a Contract has been created. - * If this field is omitted, charges will appear on a separate invoice from usage charges. - */ - class ScheduledChargesOnUsageInvoices - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var validated: Boolean = false /** - * Returns this class instance's raw value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ALL = of("ALL") + fun validate(): SpendTracker = apply { + if (validated) { + return@apply + } - @JvmStatic - fun of(value: String) = ScheduledChargesOnUsageInvoices(JsonField.of(value)) + alias() + applicableSpendSpecifiers().forEach { it.validate() } + creditTypeId() + resetFrequency().validate() + validated = true } - /** An enum containing [ScheduledChargesOnUsageInvoices]'s known values. */ - enum class Known { - ALL - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * An enum containing [ScheduledChargesOnUsageInvoices]'s known values, as well as an - * [_UNKNOWN] member. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * An instance of [ScheduledChargesOnUsageInvoices] can contain an unknown value in a - * couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Used for best match union deserialization. */ - enum class Value { - ALL, + @JvmSynthetic + internal fun validity(): Int = + (if (alias.asKnown().isPresent) 1 else 0) + + (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + + class ApplicableSpendSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sources: JsonField>, + private val spendType: JsonField, + private val discounted: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sources") + @ExcludeMissing + sources: JsonField> = JsonMissing.of(), + @JsonProperty("spend_type") + @ExcludeMissing + spendType: JsonField = JsonMissing.of(), + @JsonProperty("discounted") + @ExcludeMissing + discounted: JsonField = JsonMissing.of(), + ) : this(sources, spendType, discounted, mutableMapOf()) + /** - * An enum member indicating that [ScheduledChargesOnUsageInvoices] was instantiated - * with an unknown value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - _UNKNOWN, - } + fun sources(): List = sources.getRequired("sources") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - else -> Value._UNKNOWN - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun spendType(): SpendType = spendType.getRequired("spend_type") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - else -> - throw MetronomeInvalidDataException( - "Unknown ScheduledChargesOnUsageInvoices: $value" - ) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun discounted(): Optional = discounted.getOptional("discounted") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns the raw JSON value of [sources]. + * + * Unlike [sources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sources") + @ExcludeMissing + fun _sources(): JsonField> = sources - private var validated: Boolean = false + /** + * Returns the raw JSON value of [spendType]. + * + * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spend_type") + @ExcludeMissing + fun _spendType(): JsonField = spendType - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): ScheduledChargesOnUsageInvoices = apply { - if (validated) { - return@apply + /** + * Returns the raw JSON value of [discounted]. + * + * Unlike [discounted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discounted") + @ExcludeMissing + fun _discounted(): JsonField = discounted + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - known() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns a mutable builder for constructing an instance of + * [ApplicableSpendSpecifier]. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + */ + @JvmStatic fun builder() = Builder() } - return other is ScheduledChargesOnUsageInvoices && value == other.value - } + /** A builder for [ApplicableSpendSpecifier]. */ + class Builder internal constructor() { - override fun hashCode() = value.hashCode() + private var sources: JsonField>? = null + private var spendType: JsonField? = null + private var discounted: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = value.toString() - } + @JvmSynthetic + internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { + sources = applicableSpendSpecifier.sources.map { it.toMutableList() } + spendType = applicableSpendSpecifier.spendType + discounted = applicableSpendSpecifier.discounted + additionalProperties = + applicableSpendSpecifier.additionalProperties.toMutableMap() + } - class SpendTracker - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val alias: JsonField, - private val applicableSpendSpecifiers: JsonField>, - private val creditTypeId: JsonField, - private val resetFrequency: JsonField, - private val additionalProperties: MutableMap, - ) { + fun sources(sources: List) = sources(JsonField.of(sources)) - @JsonCreator - private constructor( - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - applicableSpendSpecifiers: JsonField> = - JsonMissing.of(), - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("reset_frequency") - @ExcludeMissing - resetFrequency: JsonField = JsonMissing.of(), - ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + /** + * Sets [Builder.sources] to an arbitrary JSON value. + * + * You should usually call [Builder.sources] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun sources(sources: JsonField>) = apply { + this.sources = sources.map { it.toMutableList() } + } - /** - * Human-readable identifier, unique per contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun alias(): String = alias.getRequired("alias") + /** + * Adds a single [Source] to [sources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: Source) = apply { + sources = + (sources ?: JsonField.of(mutableListOf())).also { + checkKnown("sources", it).add(source) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applicableSpendSpecifiers(): List = - applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + /** + * Sets [Builder.spendType] to an arbitrary JSON value. + * + * You should usually call [Builder.spendType] with a well-typed [SpendType] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun spendType(spendType: JsonField) = apply { + this.spendType = spendType + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + /** + * Sets [Builder.discounted] to an arbitrary JSON value. + * + * You should usually call [Builder.discounted] with a well-typed [Discounted] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun discounted(discounted: JsonField) = apply { + this.discounted = discounted + } - /** - * Returns the raw JSON value of [applicableSpendSpecifiers]. - * - * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - fun _applicableSpendSpecifiers(): JsonField> = - applicableSpendSpecifiers + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [resetFrequency]. - * - * Unlike [resetFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reset_frequency") - @ExcludeMissing - fun _resetFrequency(): JsonField = resetFrequency + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [ApplicableSpendSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplicableSpendSpecifier = + ApplicableSpendSpecifier( + checkRequired("sources", sources).map { it.toImmutable() }, + checkRequired("spendType", spendType), + discounted, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [SpendTracker]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SpendTracker]. */ - class Builder internal constructor() { - - private var alias: JsonField? = null - private var applicableSpendSpecifiers: - JsonField>? = - null - private var creditTypeId: JsonField? = null - private var resetFrequency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): ApplicableSpendSpecifier = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(spendTracker: SpendTracker) = apply { - alias = spendTracker.alias - applicableSpendSpecifiers = - spendTracker.applicableSpendSpecifiers.map { it.toMutableList() } - creditTypeId = spendTracker.creditTypeId - resetFrequency = spendTracker.resetFrequency - additionalProperties = spendTracker.additionalProperties.toMutableMap() + sources().forEach { it.validate() } + spendType().validate() + discounted().ifPresent { it.validate() } + validated = true } - /** Human-readable identifier, unique per contract. */ - fun alias(alias: String) = alias(JsonField.of(alias)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.alias] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun alias(alias: JsonField) = apply { this.alias = alias } + @JvmSynthetic + internal fun validity(): Int = + (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (spendType.asKnown().getOrNull()?.validity() ?: 0) + + (discounted.asKnown().getOrNull()?.validity() ?: 0) - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: List - ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + class Source + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: JsonField> - ) = apply { - this.applicableSpendSpecifiers = - applicableSpendSpecifiers.map { it.toMutableList() } - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableSpendSpecifier( - applicableSpendSpecifier: ApplicableSpendSpecifier - ) = apply { - applicableSpendSpecifiers = - (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableSpendSpecifiers", it) - .add(applicableSpendSpecifier) + companion object { + + @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + + @JvmField val MANUAL = of("MANUAL") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + THRESHOLD_RECHARGE, + MANUAL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_RECHARGE, + MANUAL, + /** + * An enum member indicating that [Source] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE + MANUAL -> Known.MANUAL + else -> throw MetronomeInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + return other is Source && value == other.value + } - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun resetFrequency(resetFrequency: ResetFrequency) = - resetFrequency(JsonField.of(resetFrequency)) + class SpendType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.resetFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.resetFrequency] with a well-typed - * [ResetFrequency] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun resetFrequency(resetFrequency: JsonField) = apply { - this.resetFrequency = resetFrequency - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An enum containing [SpendType]'s known values. */ + enum class Known { + COMMIT_PURCHASE + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [SpendType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_PURCHASE, + /** + * An enum member indicating that [SpendType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Returns an immutable instance of [SpendTracker]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SpendTracker = - SpendTracker( - checkRequired("alias", alias), - checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { - it.toImmutable() - }, - checkRequired("creditTypeId", creditTypeId), - checkRequired("resetFrequency", resetFrequency), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_PURCHASE -> Value.COMMIT_PURCHASE + else -> Value._UNKNOWN + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + COMMIT_PURCHASE -> Known.COMMIT_PURCHASE + else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): SpendTracker = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - alias() - applicableSpendSpecifiers().forEach { it.validate() } - creditTypeId() - resetFrequency().validate() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): SpendType = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (alias.asKnown().isPresent) 1 else 0) + - (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + known() + validated = true + } - class ApplicableSpendSpecifier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sources: JsonField>, - private val spendType: JsonField, - private val discounted: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("sources") - @ExcludeMissing - sources: JsonField> = JsonMissing.of(), - @JsonProperty("spend_type") - @ExcludeMissing - spendType: JsonField = JsonMissing.of(), - @JsonProperty("discounted") - @ExcludeMissing - discounted: JsonField = JsonMissing.of(), - ) : this(sources, spendType, discounted, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendType && value == other.value + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun sources(): List = sources.getRequired("sources") + override fun hashCode() = value.hashCode() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun spendType(): SpendType = spendType.getRequired("spend_type") + override fun toString() = value.toString() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun discounted(): Optional = discounted.getOptional("discounted") + class Discounted + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [sources]. - * - * Unlike [sources], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("sources") - @ExcludeMissing - fun _sources(): JsonField> = sources + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [spendType]. - * - * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("spend_type") - @ExcludeMissing - fun _spendType(): JsonField = spendType + companion object { - /** - * Returns the raw JSON value of [discounted]. - * - * Unlike [discounted], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discounted") - @ExcludeMissing - fun _discounted(): JsonField = discounted + @JvmField val ANY = of("ANY") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) + } - companion object { + /** An enum containing [Discounted]'s known values. */ + enum class Known { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + } /** - * Returns a mutable builder for constructing an instance of - * [ApplicableSpendSpecifier]. + * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] + * member. * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` + * An instance of [Discounted] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmStatic fun builder() = Builder() - } + enum class Value { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + /** + * An enum member indicating that [Discounted] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** A builder for [ApplicableSpendSpecifier]. */ - class Builder internal constructor() { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANY -> Value.ANY + DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY + else -> Value._UNKNOWN + } - private var sources: JsonField>? = null - private var spendType: JsonField? = null - private var discounted: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ANY -> Known.ANY + DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY + else -> + throw MetronomeInvalidDataException("Unknown Discounted: $value") + } - @JvmSynthetic - internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { - sources = applicableSpendSpecifier.sources.map { it.toMutableList() } - spendType = applicableSpendSpecifier.spendType - discounted = applicableSpendSpecifier.discounted - additionalProperties = - applicableSpendSpecifier.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun sources(sources: List) = sources(JsonField.of(sources)) + private var validated: Boolean = false /** - * Sets [Builder.sources] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.sources] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun sources(sources: JsonField>) = apply { - this.sources = sources.map { it.toMutableList() } + fun validate(): Discounted = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Adds a single [Source] to [sources]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Used for best match union deserialization. */ - fun addSource(source: Source) = apply { - sources = - (sources ?: JsonField.of(mutableListOf())).also { - checkKnown("sources", it).add(source) - } + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Discounted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + return other is ApplicableSpendSpecifier && + sources == other.sources && + spendType == other.spendType && + discounted == other.discounted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sources, spendType, discounted, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + } + + class ResetFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { - /** - * Sets [Builder.spendType] to an arbitrary JSON value. - * - * You should usually call [Builder.spendType] with a well-typed [SpendType] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun spendType(spendType: JsonField) = apply { - this.spendType = spendType - } + @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") - fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + } + + /** An enum containing [ResetFrequency]'s known values. */ + enum class Known { + BILLING_PERIOD + } + /** + * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResetFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILLING_PERIOD, /** - * Sets [Builder.discounted] to an arbitrary JSON value. - * - * You should usually call [Builder.discounted] with a well-typed [Discounted] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * An enum member indicating that [ResetFrequency] was instantiated with an + * unknown value. */ - fun discounted(discounted: JsonField) = apply { - this.discounted = discounted - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILLING_PERIOD -> Value.BILLING_PERIOD + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BILLING_PERIOD -> Known.BILLING_PERIOD + else -> + throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [ApplicableSpendSpecifier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ApplicableSpendSpecifier = - ApplicableSpendSpecifier( - checkRequired("sources", sources).map { it.toImmutable() }, - checkRequired("spendType", spendType), - discounted, - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false /** @@ -21787,14 +24100,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ApplicableSpendSpecifier = apply { + fun validate(): ResetFrequency = apply { if (validated) { return@apply } - sources().forEach { it.validate() } - spendType().validate() - discounted().ifPresent { it.validate() } + known() validated = true } @@ -21806,477 +24117,758 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (spendType.asKnown().getOrNull()?.validity() ?: 0) + - (discounted.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResetFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendTracker && + alias == other.alias && + applicableSpendSpecifiers == other.applicableSpendSpecifiers && + creditTypeId == other.creditTypeId && + resetFrequency == other.resetFrequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + alias, + applicableSpendSpecifiers, + creditTypeId, + resetFrequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" + } + + class Subscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val subscriptionRate: JsonField, + private val id: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val fiatCreditTypeId: JsonField, + private val initialQuantity: JsonField, + private val name: JsonField, + private val quantityManagementMode: JsonField, + private val seatConfig: JsonField, + private val startingAtOffset: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fiatCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("initial_quantity") + @ExcludeMissing + initialQuantity: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + @JsonProperty("starting_at_offset") + @ExcludeMissing + startingAtOffset: JsonField = JsonMissing.of(), + ) : this( + collectionSchedule, + proration, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + duration, + fiatCreditTypeId, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun proration(): Proration = proration.getRequired("proration") - class Source - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionRate(): SubscriptionRate = + subscriptionRate.getRequired("subscription_rate") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") - @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") - @JvmField val MANUAL = of("MANUAL") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") - /** An enum containing [Source]'s known values. */ - enum class Known { - THRESHOLD_RECHARGE, - MANUAL, - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fiatCreditTypeId(): Optional = + fiatCreditTypeId.getOptional("fiat_credit_type_id") - /** - * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_RECHARGE, - MANUAL, - /** - * An enum member indicating that [Source] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun initialQuantity(): Optional = + initialQuantity.getOptional("initial_quantity") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE - MANUAL -> Value.MANUAL - else -> Value._UNKNOWN - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE - MANUAL -> Known.MANUAL - else -> throw MetronomeInvalidDataException("Unknown Source: $value") - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * SEAT_BASED subscription to use a linked recurring credit with an allocation per seat. + * `seat_config` must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantityManagementMode(): Optional = + quantityManagementMode.getOptional("quantity_management_mode") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - private var validated: Boolean = false + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun startingAtOffset(): Optional = + startingAtOffset.getOptional("starting_at_offset") - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Source = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - known() - validated = true - } + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - return other is Source && value == other.value - } + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration - class SpendType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw JSON value of [fiatCreditTypeId]. + * + * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns the raw JSON value of [initialQuantity]. + * + * Unlike [initialQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("initial_quantity") + @ExcludeMissing + fun _initialQuantity(): JsonField = initialQuantity - companion object { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = + quantityManagementMode - @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - /** An enum containing [SpendType]'s known values. */ - enum class Known { - COMMIT_PURCHASE - } + /** + * Returns the raw JSON value of [startingAtOffset]. + * + * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at_offset") + @ExcludeMissing + fun _startingAtOffset(): JsonField = startingAtOffset - /** - * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [SpendType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_PURCHASE, - /** - * An enum member indicating that [SpendType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_PURCHASE -> Value.COMMIT_PURCHASE - else -> Value._UNKNOWN - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - COMMIT_PURCHASE -> Known.COMMIT_PURCHASE - else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") - } + fun toBuilder() = Builder().from(this) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): SpendType = apply { - if (validated) { - return@apply - } + /** A builder for [Subscription]. */ + class Builder internal constructor() { - known() - validated = true - } + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var subscriptionRate: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var fiatCreditTypeId: JsonField = JsonMissing.of() + private var initialQuantity: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quantityManagementMode: JsonField = + JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var startingAtOffset: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + collectionSchedule = subscription.collectionSchedule + proration = subscription.proration + subscriptionRate = subscription.subscriptionRate + id = subscription.id + billingCycleConfig = subscription.billingCycleConfig + customFields = subscription.customFields + description = subscription.description + duration = subscription.duration + fiatCreditTypeId = subscription.fiatCreditTypeId + initialQuantity = subscription.initialQuantity + name = subscription.name + quantityManagementMode = subscription.quantityManagementMode + seatConfig = subscription.seatConfig + startingAtOffset = subscription.startingAtOffset + additionalProperties = subscription.additionalProperties.toMutableMap() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) + + /** + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun proration(proration: Proration) = proration(JsonField.of(proration)) - return other is SpendType && value == other.value - } + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun proration(proration: JsonField) = apply { + this.proration = proration + } - override fun hashCode() = value.hashCode() + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - override fun toString() = value.toString() + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate } - class Discounted - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - companion object { + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) - @JvmField val ANY = of("ANY") + /** + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } - @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = + customFields(JsonField.of(customFields)) - @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } - @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) - } + fun description(description: String) = description(JsonField.of(description)) - /** An enum containing [Discounted]'s known values. */ - enum class Known { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Discounted] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - /** - * An enum member indicating that [Discounted] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun duration(duration: Duration) = duration(JsonField.of(duration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANY -> Value.ANY - DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY - else -> Value._UNKNOWN - } + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - ANY -> Known.ANY - DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY - else -> - throw MetronomeInvalidDataException("Unknown Discounted: $value") - } + fun fiatCreditTypeId(fiatCreditTypeId: String) = + fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { + this.fiatCreditTypeId = fiatCreditTypeId + } - private var validated: Boolean = false + fun initialQuantity(initialQuantity: Double) = + initialQuantity(JsonField.of(initialQuantity)) - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Discounted = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.initialQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.initialQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun initialQuantity(initialQuantity: JsonField) = apply { + this.initialQuantity = initialQuantity + } - known() - validated = true - } + fun name(name: String) = name(JsonField.of(name)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Determines how the subscription's quantity is controlled. Defaults to + * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly + * on the subscription. `initial_quantity` must be provided with this option. + * Compatible with recurring commits/credits that use POOLED allocation. + * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add + * user_123) to increment and decrement a subscription quantity, rather than + * directly providing the quantity. You must use a SEAT_BASED subscription to use a + * linked recurring credit with an allocation per seat. `seat_config` must be + * provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) + + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode( + quantityManagementMode: JsonField + ) = apply { this.quantityManagementMode = quantityManagementMode } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } - return other is Discounted && value == other.value - } + fun startingAtOffset(startingAtOffset: StartingAtOffset) = + startingAtOffset(JsonField.of(startingAtOffset)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.startingAtOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAtOffset] with a well-typed + * [StartingAtOffset] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun startingAtOffset(startingAtOffset: JsonField) = apply { + this.startingAtOffset = startingAtOffset + } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - return other is ApplicableSpendSpecifier && - sources == other.sources && - spendType == other.spendType && - discounted == other.discounted && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(sources, spendType, discounted, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode + /** + * Returns an immutable instance of [Subscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("subscriptionRate", subscriptionRate), + id, + billingCycleConfig, + customFields, + description, + duration, + fiatCreditTypeId, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAtOffset, + additionalProperties.toMutableMap(), + ) + } - override fun toString() = - "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + collectionSchedule().validate() + proration().validate() + subscriptionRate().validate() + id() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + duration().ifPresent { it.validate() } + fiatCreditTypeId() + initialQuantity() + name() + quantityManagementMode().ifPresent { it.validate() } + seatConfig().ifPresent { it.validate() } + startingAtOffset().ifPresent { it.validate() } + validated = true } - class ResetFrequency + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + + (if (initialQuantity.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + + class CollectionSchedule @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22292,21 +24884,24 @@ private constructor( companion object { - @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + @JvmField val ADVANCE = of("ADVANCE") - @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - /** An enum containing [ResetFrequency]'s known values. */ + /** An enum containing [CollectionSchedule]'s known values. */ enum class Known { - BILLING_PERIOD + ADVANCE, + ARREARS, } /** - * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [ResetFrequency] can contain an unknown value in a couple of + * An instance of [CollectionSchedule] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with @@ -22314,9 +24909,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILLING_PERIOD, + ADVANCE, + ARREARS, /** - * An enum member indicating that [ResetFrequency] was instantiated with an + * An enum member indicating that [CollectionSchedule] was instantiated with an * unknown value. */ _UNKNOWN, @@ -22331,7 +24927,8 @@ private constructor( */ fun value(): Value = when (this) { - BILLING_PERIOD -> Value.BILLING_PERIOD + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS else -> Value._UNKNOWN } @@ -22346,9 +24943,12 @@ private constructor( */ fun known(): Known = when (this) { - BILLING_PERIOD -> Known.BILLING_PERIOD + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS else -> - throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + throw MetronomeInvalidDataException( + "Unknown CollectionSchedule: $value" + ) } /** @@ -22377,7 +24977,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ResetFrequency = apply { + fun validate(): CollectionSchedule = apply { if (validated) { return@apply } @@ -22407,902 +25007,871 @@ private constructor( return true } - return other is ResetFrequency && value == other.value + return other is CollectionSchedule && value == other.value } override fun hashCode() = value.hashCode() - override fun toString() = value.toString() - } + override fun toString() = value.toString() + } + + class Proration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("invoice_behavior") + @ExcludeMissing + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun invoiceBehavior(): InvoiceBehavior = + invoiceBehavior.getRequired("invoice_behavior") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + + /** + * Returns the raw JSON value of [invoiceBehavior]. + * + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_behavior") + @ExcludeMissing + fun _invoiceBehavior(): JsonField = invoiceBehavior + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is SpendTracker && - alias == other.alias && - applicableSpendSpecifiers == other.applicableSpendSpecifiers && - creditTypeId == other.creditTypeId && - resetFrequency == other.resetFrequency && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - alias, - applicableSpendSpecifiers, - creditTypeId, - resetFrequency, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "SpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Proration]. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class Subscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val subscriptionRate: JsonField, - private val id: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val duration: JsonField, - private val fiatCreditTypeId: JsonField, - private val initialQuantity: JsonField, - private val name: JsonField, - private val quantityManagementMode: JsonField, - private val seatConfig: JsonField, - private val startingAtOffset: JsonField, - private val additionalProperties: MutableMap, - ) { + /** A builder for [Proration]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fiatCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("initial_quantity") - @ExcludeMissing - initialQuantity: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - @JsonProperty("starting_at_offset") - @ExcludeMissing - startingAtOffset: JsonField = JsonMissing.of(), - ) : this( - collectionSchedule, - proration, - subscriptionRate, - id, - customFields, - description, - duration, - fiatCreditTypeId, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - mutableMapOf(), - ) + private var invoiceBehavior: JsonField? = null + private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + @JvmSynthetic + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun proration(): Proration = proration.getRequired("proration") + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionRate(): SubscriptionRate = - subscriptionRate.getRequired("subscription_rate") + /** + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun fiatCreditTypeId(): Optional = - fiatCreditTypeId.getOptional("fiat_credit_type_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun initialQuantity(): Optional = - initialQuantity.getOptional("initial_quantity") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * SEAT_BASED subscription to use a linked recurring credit with an allocation per seat. - * `seat_config` must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantityManagementMode(): Optional = - quantityManagementMode.getOptional("quantity_management_mode") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun startingAtOffset(): Optional = - startingAtOffset.getOptional("starting_at_offset") + /** + * Returns an immutable instance of [Proration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Proration = + Proration( + checkRequired("invoiceBehavior", invoiceBehavior), + checkRequired("isProrated", isProrated), + rounding, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + private var validated: Boolean = false - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + invoiceBehavior().validate() + isProrated() + rounding().ifPresent { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [fiatCreditTypeId]. - * - * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId + companion object { - /** - * Returns the raw JSON value of [initialQuantity]. - * - * Unlike [initialQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("initial_quantity") - @ExcludeMissing - fun _initialQuantity(): JsonField = initialQuantity + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JvmField + val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = - quantityManagementMode + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } - /** - * Returns the raw JSON value of [startingAtOffset]. - * - * Unlike [startingAtOffset], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at_offset") - @ExcludeMissing - fun _startingAtOffset(): JsonField = startingAtOffset + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException( + "Unknown InvoiceBehavior: $value" + ) + } - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - companion object { + private var validated: Boolean = false - /** - * Returns a mutable builder for constructing an instance of [Subscription]. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - /** A builder for [Subscription]. */ - class Builder internal constructor() { + known() + validated = true + } - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var subscriptionRate: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var fiatCreditTypeId: JsonField = JsonMissing.of() - private var initialQuantity: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantityManagementMode: JsonField = - JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var startingAtOffset: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - collectionSchedule = subscription.collectionSchedule - proration = subscription.proration - subscriptionRate = subscription.subscriptionRate - id = subscription.id - customFields = subscription.customFields - description = subscription.description - duration = subscription.duration - fiatCreditTypeId = subscription.fiatCreditTypeId - initialQuantity = subscription.initialQuantity - name = subscription.name - quantityManagementMode = subscription.quantityManagementMode - seatConfig = subscription.seatConfig - startingAtOffset = subscription.startingAtOffset - additionalProperties = subscription.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule - } + return other is InvoiceBehavior && value == other.value + } - fun proration(proration: Proration) = proration(JsonField.of(proration)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun proration(proration: JsonField) = apply { - this.proration = proration + override fun toString() = value.toString() } - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - fun id(id: String) = id(JsonField.of(id)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit. For USD, this means rounding to the nearest + * dollar). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = - customFields(JsonField.of(customFields)) + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun description(description: String) = description(JsonField.of(description)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun duration(duration: Duration) = duration(JsonField.of(duration)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Duration] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } + companion object { - fun fiatCreditTypeId(fiatCreditTypeId: String) = - fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { - this.fiatCreditTypeId = fiatCreditTypeId - } + /** A builder for [Rounding]. */ + class Builder internal constructor() { - fun initialQuantity(initialQuantity: Double) = - initialQuantity(JsonField.of(initialQuantity)) + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.initialQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.initialQuantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun initialQuantity(initialQuantity: JsonField) = apply { - this.initialQuantity = initialQuantity - } + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - fun name(name: String) = name(JsonField.of(name)) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit. For USD, this means rounding to + * the nearest dollar). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Determines how the subscription's quantity is controlled. Defaults to - * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly - * on the subscription. `initial_quantity` must be provided with this option. - * Compatible with recurring commits/credits that use POOLED allocation. - * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add - * user_123) to increment and decrement a subscription quantity, rather than - * directly providing the quantity. You must use a SEAT_BASED subscription to use a - * linked recurring credit with an allocation per seat. `seat_config` must be - * provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode( - quantityManagementMode: JsonField - ) = apply { this.quantityManagementMode = quantityManagementMode } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun startingAtOffset(startingAtOffset: StartingAtOffset) = - startingAtOffset(JsonField.of(startingAtOffset)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.startingAtOffset] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAtOffset] with a well-typed - * [StartingAtOffset] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun startingAtOffset(startingAtOffset: JsonField) = apply { - this.startingAtOffset = startingAtOffset - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns an immutable instance of [Subscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Subscription = - Subscription( - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("subscriptionRate", subscriptionRate), - id, - customFields, - description, - duration, - fiatCreditTypeId, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAtOffset, - additionalProperties.toMutableMap(), - ) - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - private var validated: Boolean = false + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Subscription = apply { - if (validated) { - return@apply - } + companion object { - collectionSchedule().validate() - proration().validate() - subscriptionRate().validate() - id() - customFields().ifPresent { it.validate() } - description() - duration().ifPresent { it.validate() } - fiatCreditTypeId() - initialQuantity() - name() - quantityManagementMode().ifPresent { it.validate() } - seatConfig().ifPresent { it.validate() } - startingAtOffset().ifPresent { it.validate() } - validated = true - } + @JvmField val HALF_UP = of("HALF_UP") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmField val FLOOR = of("FLOOR") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (duration.asKnown().getOrNull()?.validity() ?: 0) + - (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + - (if (initialQuantity.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + - (startingAtOffset.asKnown().getOrNull()?.validity() ?: 0) + @JvmField val CEILING = of("CEILING") - class CollectionSchedule - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - companion object { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmField val ADVANCE = of("ADVANCE") + private var validated: Boolean = false - @JvmField val ARREARS = of("ARREARS") + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } + known() + validated = true + } - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException( - "Unknown CollectionSchedule: $value" - ) - } + return other is RoundingMethod && value == other.value + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CollectionSchedule && value == other.value + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" } - class Proration + class SubscriptionRate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val billingFrequency: JsonField, + private val product: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + product: JsonField = JsonMissing.of(), + ) : this(billingFrequency, product, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun invoiceBehavior(): InvoiceBehavior = - invoiceBehavior.getRequired("invoice_behavior") + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + fun product(): Product = product.getRequired("product") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [billingFrequency]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("billing_frequency") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _billingFrequency(): JsonField = billingFrequency /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [product]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [product], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("is_prorated") + @JsonProperty("product") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _product(): JsonField = product @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23319,57 +25888,55 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Proration]. + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .billingFrequency() + * .product() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [SubscriptionRate]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField? = null - private var isProrated: JsonField? = null + private var billingFrequency: JsonField? = null + private var product: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + product = subscriptionRate.product + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() } - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency } - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + fun product(product: Product) = product(JsonField.of(product)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.product] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } + fun product(product: JsonField) = apply { this.product = product } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -23394,22 +25961,22 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [SubscriptionRate]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .billingFrequency() + * .product() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration( - checkRequired("invoiceBehavior", invoiceBehavior), - checkRequired("isProrated", isProrated), + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("product", product), additionalProperties.toMutableMap(), ) } @@ -23426,13 +25993,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Proration = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - invoiceBehavior().validate() - isProrated() + billingFrequency().validate() + product().validate() validated = true } @@ -23452,10 +26019,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) - class InvoiceBehavior + class BillingFrequency @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23470,90 +26037,306 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - companion object { + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + } + + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } + + /** + * An enum containing [BillingFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BillingFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [BillingFrequency] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException( + "Unknown BillingFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): BillingFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Product]. */ + class Builder internal constructor() { - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmField - val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) - } + fun id(id: String) = id(JsonField.of(id)) - /** An enum containing [InvoiceBehavior]'s known values. */ - enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) - /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an - * unknown value. + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun name(name: JsonField) = apply { this.name = name } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE - else -> - throw MetronomeInvalidDataException( - "Unknown InvoiceBehavior: $value" - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -23566,12 +26349,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): InvoiceBehavior = apply { + fun validate(): Product = apply { if (validated) { return@apply } - known() + id() + name() validated = true } @@ -23590,19 +26374,29 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is InvoiceBehavior && value == other.value + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -23610,74 +26404,52 @@ private constructor( return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + product == other.product && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(billingFrequency, product, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" } - class SubscriptionRate + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val billingFrequency: JsonField, - private val product: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product") + @JsonProperty("invoice_placement") @ExcludeMissing - product: JsonField = JsonMissing.of(), - ) : this(billingFrequency, product, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + invoicePlacement: JsonField = JsonMissing.of() + ) : this(invoicePlacement, mutableMapOf()) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun product(): Product = product.getRequired("product") + fun invoicePlacement(): Optional = + invoicePlacement.getOptional("invoice_placement") /** - * Returns the raw JSON value of [billingFrequency]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("billing_frequency") - @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency - - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product") + @JsonProperty("invoice_placement") @ExcludeMissing - fun _product(): JsonField = product + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23694,56 +26466,39 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` + * Returns a mutable builder for constructing an instance of + * [BillingCycleConfig]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionRate]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var billingFrequency: JsonField? = null - private var product: JsonField? = null + private var invoicePlacement: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - product = subscriptionRate.product - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = + billingCycleConfig.additionalProperties.toMutableMap() } - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement } - fun product(product: Product) = product(JsonField.of(product)) - - /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun product(product: JsonField) = apply { this.product = product } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23767,24 +26522,12 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionRate]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("product", product), - additionalProperties.toMutableMap(), - ) + fun build(): BillingCycleConfig = + BillingCycleConfig(invoicePlacement, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -23799,13 +26542,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): SubscriptionRate = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - billingFrequency().validate() - product().validate() + invoicePlacement().ifPresent { it.validate() } validated = true } @@ -23825,10 +26567,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) - class BillingFrequency + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23845,30 +26586,24 @@ private constructor( companion object { - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") - - @JvmField val ANNUAL = of("ANNUAL") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField val WEEKLY = of("WEEKLY") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [BillingFrequency]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [BillingFrequency]'s known values, as well as an + * An enum containing [InvoicePlacement]'s known values, as well as an * [_UNKNOWN] member. * - * An instance of [BillingFrequency] can contain an unknown value in a couple of + * An instance of [InvoicePlacement] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may @@ -23876,12 +26611,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [BillingFrequency] was instantiated with + * An enum member indicating that [InvoicePlacement] was instantiated with * an unknown value. */ _UNKNOWN, @@ -23896,10 +26629,8 @@ private constructor( */ fun value(): Value = when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -23914,13 +26645,11 @@ private constructor( */ fun known(): Known = when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE else -> throw MetronomeInvalidDataException( - "Unknown BillingFrequency: $value" + "Unknown InvoicePlacement: $value" ) } @@ -23950,7 +26679,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): BillingFrequency = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -23981,7 +26710,7 @@ private constructor( return true } - return other is BillingFrequency && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -23989,241 +26718,24 @@ private constructor( override fun toString() = value.toString() } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Product]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - product == other.product && + return other is BillingCycleConfig && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(billingFrequency, product, additionalProperties) + Objects.hash(invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + "BillingCycleConfig{invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ @@ -25436,6 +27948,7 @@ private constructor( proration == other.proration && subscriptionRate == other.subscriptionRate && id == other.id && + billingCycleConfig == other.billingCycleConfig && customFields == other.customFields && description == other.description && duration == other.duration && @@ -25454,6 +27967,7 @@ private constructor( proration, subscriptionRate, id, + billingCycleConfig, customFields, description, duration, @@ -25470,7 +27984,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, duration=$duration, fiatCreditTypeId=$fiatCreditTypeId, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, additionalProperties=$additionalProperties}" + "Subscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, duration=$duration, fiatCreditTypeId=$fiatCreditTypeId, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAtOffset=$startingAtOffset, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditParams.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditParams.kt index b681cc87..8843ed1e 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditParams.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditParams.kt @@ -14048,6 +14048,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -14060,6 +14061,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -14082,6 +14086,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -14092,6 +14097,19 @@ private constructor( mutableMapOf(), ) + /** + * Can only be used for commit specific overrides. Must be used in conjunction with one + * of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified commit, + * credit, recurring commit or recurring credit IDs. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -14157,6 +14175,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -14251,6 +14279,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -14263,6 +14292,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -14274,6 +14305,39 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + /** + * Can only be used for commit specific overrides. Must be used in conjunction with + * one of `product_id`, `product_tags`, `pricing_group_values`, or + * `presentation_group_values`. Must be used instead of both `commit_ids` and + * `recurring_commit_ids` If provided, the override will apply to any specified + * commit, credit, recurring commit or recurring credit IDs. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = apply { + this.anyCommitOrCreditIds = anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -14459,6 +14523,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -14487,6 +14552,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -14513,7 +14579,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -14934,6 +15001,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -14946,6 +15014,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -14960,7 +15029,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } /** Required for OVERWRITE type. */ @@ -17024,6 +17093,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, @@ -17075,6 +17145,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), @@ -17108,6 +17181,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -17234,6 +17308,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Optional rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * Whether the created commits will use the commit rate or list rate * @@ -17423,6 +17506,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [rateType]. * @@ -17525,6 +17618,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -17551,6 +17645,7 @@ private constructor( name = addRecurringCommit.name netsuiteSalesOrderId = addRecurringCommit.netsuiteSalesOrderId proration = addRecurringCommit.proration + prorationRounding = addRecurringCommit.prorationRounding rateType = addRecurringCommit.rateType recurrenceFrequency = addRecurringCommit.recurrenceFrequency rolloverFraction = addRecurringCommit.rolloverFraction @@ -17785,6 +17880,21 @@ private constructor( */ fun proration(proration: JsonField) = apply { this.proration = proration } + /** Optional rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** Whether the created commits will use the commit rate or list rate */ fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -17953,6 +18063,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, rateType, recurrenceFrequency, rolloverFraction, @@ -17993,6 +18104,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() @@ -18032,6 +18144,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + @@ -19062,97 +19175,138 @@ private constructor( override fun toString() = value.toString() } - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Optional rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun access(): Optional = access.getOptional("access") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - @JvmField val LIST_RATE = of("LIST_RATE") + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_RATE, - LIST_RATE, /** - * An enum member indicating that [RateType] was instantiated with an unknown value. + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -19165,12 +19319,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -19188,471 +19343,455 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RateType && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val QUARTERLY = of("QUARTERLY") + fun toBuilder() = Builder().from(this) - @JvmField val ANNUAL = of("ANNUAL") + companion object { - @JvmField val WEEKLY = of("WEEKLY") + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) - } + /** A builder for [Access]. */ + class Builder internal constructor() { - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - private var validated: Boolean = false + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RecurrenceFrequency = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - known() - validated = true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - return other is RecurrenceFrequency && value == other.value - } + private var validated: Boolean = false - override fun hashCode() = value.hashCode() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - override fun toString() = value.toString() - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val applySeatIncreaseConfig: JsonField, - private val subscriptionId: JsonField, - private val allocation: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_id") - @ExcludeMissing - subscriptionId: JsonField = JsonMissing.of(), - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * ID of the subscription to configure on the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun allocation(): Optional = allocation.getOptional("allocation") + companion object { - /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns the raw JSON value of [subscriptionId]. - * - * Unlike [subscriptionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_id") - @ExcludeMissing - fun _subscriptionId(): JsonField = subscriptionId + @JvmField val FLOOR = of("FLOOR") - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + @JvmField val CEILING = of("CEILING") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - fun toBuilder() = Builder().from(this) + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** A builder for [SubscriptionConfig]. */ - class Builder internal constructor() { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionId: JsonField? = null - private var allocation: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionId = subscriptionConfig.subscriptionId - allocation = subscriptionConfig.allocation - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - - /** ID of the subscription to configure on the recurring commit/credit. */ - fun subscriptionId(subscriptionId: String) = - subscriptionId(JsonField.of(subscriptionId)) + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Sets [Builder.subscriptionId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun subscriptionId(subscriptionId: JsonField) = apply { - this.subscriptionId = subscriptionId - } + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") /** - * If set to POOLED, allocation added per seat is pooled across the account. If set - * to INDIVIDUAL, each seat in the subscription will have its own allocation. + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Returns the raw JSON value of [roundingMethod]. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SubscriptionConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionId", subscriptionId), - allocation, - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): SubscriptionConfig = apply { - if (validated) { - return@apply - } - - applySeatIncreaseConfig().validate() - subscriptionId() - allocation().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionId.asKnown().isPresent) 1 else 0) + - (allocation.asKnown().getOrNull()?.validity() ?: 0) - - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) - - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -19669,42 +19808,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ApplySeatIncreaseConfig]. + * Returns a mutable builder for constructing an instance of [Invoice]. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ApplySeatIncreaseConfig]. */ + /** A builder for [Invoice]. */ class Builder internal constructor() { - private var isProrated: JsonField? = null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = apply { @@ -19730,20 +19889,22 @@ private constructor( } /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .isProrated() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -19760,12 +19921,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ApplySeatIncreaseConfig = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - isProrated() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -19784,170 +19946,184 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } - - override fun hashCode(): Int = hashCode + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - */ - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + companion object { - companion object { + @JvmField val HALF_UP = of("HALF_UP") - @JvmField val POOLED = of("POOLED") + @JvmField val FLOOR = of("FLOOR") - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + @JvmField val CEILING = of("CEILING") - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - POOLED, - INDIVIDUAL, - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Allocation] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - POOLED, - INDIVIDUAL, /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - POOLED -> Value.POOLED - INDIVIDUAL -> Value.INDIVIDUAL - else -> Value._UNKNOWN + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - POOLED -> Known.POOLED - INDIVIDUAL -> Known.INDIVIDUAL - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - private var validated: Boolean = false + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true } - known() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Allocation && value == other.value + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -19955,1689 +20131,4880 @@ private constructor( return true } - return other is SubscriptionConfig && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionId == other.subscriptionId && - allocation == other.allocation && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - applySeatIncreaseConfig, - subscriptionId, - allocation, - additionalProperties, - ) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is AddRecurringCommit && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - productId == other.productId && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - rateType == other.rateType && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - temporaryId == other.temporaryId && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - accessAmount, - commitDuration, - priority, - productId, - startingAt, - applicableProductIds, - applicableProductTags, - description, - endingBefore, - hierarchyConfiguration, - invoiceAmount, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - override fun toString() = - "AddRecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" - } + @JvmField val LIST_RATE = of("LIST_RATE") - class AddRecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val startingAt: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val endingBefore: JsonField, - private val hierarchyConfiguration: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val proration: JsonField, - private val rateType: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - @JsonCreator - private constructor( - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") - @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") - @ExcludeMissing - subscriptionConfig: JsonField = JsonMissing.of(), - @JsonProperty("temporary_id") - @ExcludeMissing - temporaryId: JsonField = JsonMissing.of(), - ) : this( - accessAmount, - commitDuration, - priority, - productId, - startingAt, - applicableProductIds, - applicableProductTags, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - mutableMapOf(), - ) + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a period - * is determined by the recurrence_frequency. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applySeatIncreaseConfig: JsonField, + private val subscriptionId: JsonField, + private val allocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + + /** + * ID of the subscription to configure on the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allocation(): Optional = allocation.getOptional("allocation") + + /** + * Returns the raw JSON value of [applySeatIncreaseConfig]. + * + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + @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 [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { + + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionId = subscriptionConfig.subscriptionId + allocation = subscriptionConfig.allocation + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + } + + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) + + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } + + /** ID of the subscription to configure on the recurring commit/credit. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set + * to INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionId", subscriptionId), + allocation, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + applySeatIncreaseConfig().validate() + subscriptionId() + allocation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (allocation.asKnown().getOrNull()?.validity() ?: 0) + + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) + + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + @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 + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { + + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } + + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } + + isProrated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val POOLED = of("POOLED") + + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) + } + + /** An enum containing [Allocation]'s known values. */ + enum class Known { + POOLED, + INDIVIDUAL, + } + + /** + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + POOLED, + INDIVIDUAL, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + POOLED -> Value.POOLED + INDIVIDUAL -> Value.INDIVIDUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + POOLED -> Known.POOLED + INDIVIDUAL -> Known.INDIVIDUAL + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Allocation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allocation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionConfig && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionId == other.subscriptionId && + allocation == other.allocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applySeatIncreaseConfig, + subscriptionId, + allocation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddRecurringCommit && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + productId == other.productId && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + rateType == other.rateType && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + temporaryId == other.temporaryId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessAmount, + commitDuration, + priority, + productId, + startingAt, + applicableProductIds, + applicableProductTags, + description, + endingBefore, + hierarchyConfiguration, + invoiceAmount, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddRecurringCommit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + } + + class AddRecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val startingAt: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val endingBefore: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_amount") + @ExcludeMissing + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = JsonMissing.of(), + @JsonProperty("temporary_id") + @ExcludeMissing + temporaryId: JsonField = JsonMissing.of(), + ) : this( + accessAmount, + commitDuration, + priority, + productId, + startingAt, + applicableProductIds, + applicableProductTags, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + mutableMapOf(), + ) + + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a period + * is determined by the recurrence_frequency. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priority(): Double = priority.getRequired("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun productId(): String = productId.getRequired("product_id") + + /** + * determines the start time for the first commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Determines when the contract will stop creating recurring commits. optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * Optional configuration for recurring credit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") + + /** + * displayed on invoices. will be passed through to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") + + /** + * Optional rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") + + /** + * Will be passed down to the individual commits. This controls how much of an individual + * unexpired commit will roll over upon contract transition. Must be between 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or credit. + * A customer's usage needs to meet the condition of at least one of the specifiers to + * contribute to a commit's or credit's drawdown. This field cannot be used together with + * `applicable_product_ids` or `applicable_product_tags`. Instead, to target usage by + * product or product tag, pass those values in the body of `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") + + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") + + /** + * A temporary ID that can be used to reference the recurring commit for commit specific + * overrides. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount + + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration + + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency + + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = subscriptionConfig + + /** + * Returns the raw JSON value of [temporaryId]. + * + * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temporary_id") + @ExcludeMissing + fun _temporaryId(): JsonField = temporaryId + + @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 [AddRecurringCredit]. + * + * The following fields are required: + * ```java + * .accessAmount() + * .commitDuration() + * .priority() + * .productId() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddRecurringCredit]. */ + class Builder internal constructor() { + + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var productId: JsonField? = null + private var startingAt: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = JsonMissing.of() + private var temporaryId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addRecurringCredit: AddRecurringCredit) = apply { + accessAmount = addRecurringCredit.accessAmount + commitDuration = addRecurringCredit.commitDuration + priority = addRecurringCredit.priority + productId = addRecurringCredit.productId + startingAt = addRecurringCredit.startingAt + applicableProductIds = + addRecurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addRecurringCredit.applicableProductTags.map { it.toMutableList() } + description = addRecurringCredit.description + endingBefore = addRecurringCredit.endingBefore + hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration + name = addRecurringCredit.name + netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId + proration = addRecurringCredit.proration + prorationRounding = addRecurringCredit.prorationRounding + rateType = addRecurringCredit.rateType + recurrenceFrequency = addRecurringCredit.recurrenceFrequency + rolloverFraction = addRecurringCredit.rolloverFraction + specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = addRecurringCredit.subscriptionConfig + temporaryId = addRecurringCredit.temporaryId + additionalProperties = addRecurringCredit.additionalProperties.toMutableMap() + } + + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a + * period is determined by the recurrence_frequency. + */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) + + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } + + /** Will be passed down to the individual commits */ + fun priority(priority: Double) = priority(JsonField.of(priority)) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + fun productId(productId: String) = productId(JsonField.of(productId)) + + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } + + /** determines the start time for the first commit */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + /** Will be passed down to the individual commits */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Determines when the contract will stop creating recurring commits. optional */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + /** Optional configuration for recurring credit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + + /** displayed on invoices. will be passed through to the individual commits */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Will be passed down to the individual commits */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) + + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } + + /** Optional rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding) = + prorationRounding(JsonField.of(prorationRounding)) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) + + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { + this.recurrenceFrequency = recurrenceFrequency + } + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be between + * 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to + * target usage by product or product tag, pass those values in the body of + * `specifiers`. + */ + fun specifiers(specifiers: List) = + specifiers(JsonField.of(specifiers)) + + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [SubscriptionConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionConfig(subscriptionConfig: JsonField) = apply { + this.subscriptionConfig = subscriptionConfig + } + + /** + * A temporary ID that can be used to reference the recurring commit for commit specific + * overrides. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AddRecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessAmount() + * .commitDuration() + * .priority() + * .productId() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddRecurringCredit = + AddRecurringCredit( + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("productId", productId), + checkRequired("startingAt", startingAt), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + temporaryId, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddRecurringCredit = apply { + if (validated) { + return@apply + } + + accessAmount().validate() + commitDuration().validate() + priority() + productId() + startingAt() + applicableProductIds() + applicableProductTags() + description() + endingBefore() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + temporaryId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") + + /** + * This field is required unless a subscription is attached via `subscription_config`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @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 [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** + * This field is required unless a subscription is attached via + * `subscription_config`. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + creditTypeId() + unitPrice() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + /** + * Defines the length of the access schedule for each created commit/credit. The value + * represents the number of units. Unit defaults to "PERIODS", where the length of a period + * is determined by the recurrence_frequency. + */ + class CommitDuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val unit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): Double = value.getRequired("value") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @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 [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } + + value() + unit().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERIODS = of("PERIODS") + + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } + + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS + } + + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Optional rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + @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 [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply + } + + access().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priority(): Double = priority.getRequired("priority") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun productId(): String = productId.getRequired("product_id") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * determines the start time for the first commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + private var validated: Boolean = false - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + known() + validated = true + } - /** - * Determines when the contract will stop creating recurring commits. optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Optional configuration for recurring credit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * displayed on invoices. will be passed through to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + return other is RoundingMethod && value == other.value + } - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun proration(): Optional = proration.getOptional("proration") + override fun hashCode() = value.hashCode() - /** - * Whether the created commits will use the commit rate or list rate - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + override fun toString() = value.toString() + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Will be passed down to the individual commits. This controls how much of an individual - * unexpired commit will roll over upon contract transition. Must be between 0 and 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } - /** - * List of filters that determine what kind of customer usage draws down a commit or credit. - * A customer's usage needs to meet the condition of at least one of the specifiers to - * contribute to a commit's or credit's drawdown. This field cannot be used together with - * `applicable_product_ids` or `applicable_product_tags`. Instead, to target usage by - * product or product tag, pass those values in the body of `specifiers`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - /** - * Attach a subscription to the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") + override fun hashCode(): Int = hashCode - /** - * A temporary ID that can be used to reference the recurring commit for commit specific - * overrides. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + companion object { - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + @JvmField val LIST_RATE = of("LIST_RATE") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [recurrenceFrequency]. - * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recurrence_frequency") - @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + private var validated: Boolean = false - /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") - @ExcludeMissing - fun _subscriptionConfig(): JsonField = subscriptionConfig + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [temporaryId]. - * - * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("temporary_id") - @ExcludeMissing - fun _temporaryId(): JsonField = temporaryId + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is RateType && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period defined + * in the duration will correspond to this frequency. - Commits will be created aligned with + * the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of [AddRecurringCredit]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .accessAmount() - * .commitDuration() - * .priority() - * .productId() - * .startingAt() - * ``` + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [AddRecurringCredit]. */ - class Builder internal constructor() { + companion object { - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var productId: JsonField? = null - private var startingAt: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = JsonMissing.of() - private var temporaryId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val MONTHLY = of("MONTHLY") - @JvmSynthetic - internal fun from(addRecurringCredit: AddRecurringCredit) = apply { - accessAmount = addRecurringCredit.accessAmount - commitDuration = addRecurringCredit.commitDuration - priority = addRecurringCredit.priority - productId = addRecurringCredit.productId - startingAt = addRecurringCredit.startingAt - applicableProductIds = - addRecurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addRecurringCredit.applicableProductTags.map { it.toMutableList() } - description = addRecurringCredit.description - endingBefore = addRecurringCredit.endingBefore - hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration - name = addRecurringCredit.name - netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId - proration = addRecurringCredit.proration - rateType = addRecurringCredit.rateType - recurrenceFrequency = addRecurringCredit.recurrenceFrequency - rolloverFraction = addRecurringCredit.rolloverFraction - specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = addRecurringCredit.subscriptionConfig - temporaryId = addRecurringCredit.temporaryId - additionalProperties = addRecurringCredit.additionalProperties.toMutableMap() + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) } - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, } /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a - * period is determined by the recurrence_frequency. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.commitDuration] with a well-typed [CommitDuration] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true } - /** Will be passed down to the individual commits */ - fun priority(priority: Double) = priority(JsonField.of(priority)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.priority] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.priority] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun priority(priority: JsonField) = apply { this.priority = priority } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun productId(productId: String) = productId(JsonField.of(productId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Attach a subscription to the recurring commit/credit. */ + class SubscriptionConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applySeatIncreaseConfig: JsonField, + private val subscriptionId: JsonField, + private val allocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + applySeatIncreaseConfig: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun productId(productId: JsonField) = apply { this.productId = productId } - - /** determines the start time for the first commit */ - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = + applySeatIncreaseConfig.getRequired("apply_seat_increase_config") /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * ID of the subscription to configure on the recurring commit/credit. * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } - - /** Will be passed down to the individual commits */ - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + fun allocation(): Optional = allocation.getOptional("allocation") /** - * Adds a single [String] to [applicableProductIds]. + * Returns the raw JSON value of [applySeatIncreaseConfig]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } - - /** Will be passed down to the individual commits */ - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + @JsonProperty("apply_seat_increase_config") + @ExcludeMissing + fun _applySeatIncreaseConfig(): JsonField = + applySeatIncreaseConfig /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * Returns the raw JSON value of [subscriptionId]. * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId /** - * Adds a single [String] to [applicableProductTags]. + * Returns the raw JSON value of [allocation]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** Will be passed down to the individual commits */ - fun description(description: String) = description(JsonField.of(description)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + fun toBuilder() = Builder().from(this) - /** Determines when the contract will stop creating recurring commits. optional */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + companion object { - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + /** + * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** Optional configuration for recurring credit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + /** A builder for [SubscriptionConfig]. */ + class Builder internal constructor() { - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + private var applySeatIncreaseConfig: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** displayed on invoices. will be passed through to the individual commits */ - fun name(name: String) = name(JsonField.of(name)) + @JvmSynthetic + internal fun from(subscriptionConfig: SubscriptionConfig) = apply { + applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig + subscriptionId = subscriptionConfig.subscriptionId + allocation = subscriptionConfig.allocation + additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = + applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) - /** Will be passed down to the individual commits */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + /** + * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed + * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applySeatIncreaseConfig( + applySeatIncreaseConfig: JsonField + ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + /** ID of the subscription to configure on the recurring commit/credit. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun proration(proration: JsonField) = apply { this.proration = proration } + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set + * to INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = apply { - this.recurrenceFrequency = recurrenceFrequency - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be between - * 0 and 1. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction + /** + * Returns an immutable instance of [SubscriptionConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .applySeatIncreaseConfig() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionConfig = + SubscriptionConfig( + checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), + checkRequired("subscriptionId", subscriptionId), + allocation, + additionalProperties.toMutableMap(), + ) } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to - * target usage by product or product tag, pass those values in the body of - * `specifiers`. - */ - fun specifiers(specifiers: List) = - specifiers(JsonField.of(specifiers)) + private var validated: Boolean = false /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } - - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } + fun validate(): SubscriptionConfig = apply { + if (validated) { + return@apply + } + + applySeatIncreaseConfig().validate() + subscriptionId() + allocation().ifPresent { it.validate() } + validated = true } - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: SubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [SubscriptionConfig] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun subscriptionConfig(subscriptionConfig: JsonField) = apply { - this.subscriptionConfig = subscriptionConfig - } + @JvmSynthetic + internal fun validity(): Int = + (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (allocation.asKnown().getOrNull()?.validity() ?: 0) - /** - * A temporary ID that can be used to reference the recurring commit for commit specific - * overrides. - */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + class ApplySeatIncreaseConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val isProrated: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. - * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } + @JsonCreator + private constructor( + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of() + ) : this(isProrated, mutableMapOf()) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Indicates whether a mid-period seat increase should be prorated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [isProrated]. + * + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [AddRecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessAmount() - * .commitDuration() - * .priority() - * .productId() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddRecurringCredit = - AddRecurringCredit( - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("productId", productId), - checkRequired("startingAt", startingAt), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - temporaryId, - additionalProperties.toMutableMap(), - ) - } + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ApplySeatIncreaseConfig]. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApplySeatIncreaseConfig]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var isProrated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddRecurringCredit = apply { - if (validated) { - return@apply - } + @JvmSynthetic + internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { + isProrated = applySeatIncreaseConfig.isProrated + additionalProperties = + applySeatIncreaseConfig.additionalProperties.toMutableMap() + } - accessAmount().validate() - commitDuration().validate() - priority() - productId() - startingAt() - applicableProductIds() - applicableProductTags() - description() - endingBefore() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - proration().ifPresent { it.validate() } - rateType().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - temporaryId() - validated = true - } + /** Indicates whether a mid-period seat increase should be prorated. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * This field is required unless a subscription is attached via `subscription_config`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + /** + * Returns an immutable instance of [ApplySeatIncreaseConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplySeatIncreaseConfig = + ApplySeatIncreaseConfig( + checkRequired("isProrated", isProrated), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + private var validated: Boolean = false - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ApplySeatIncreaseConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + isProrated() + validated = true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) - fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return other is ApplySeatIncreaseConfig && + isProrated == other.isProrated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" + } + + /** + * If set to POOLED, allocation added per seat is pooled across the account. If set to + * INDIVIDUAL, each seat in the subscription will have its own allocation. + */ + class Allocation + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of [AccessAmount]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + companion object { - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val POOLED = of("POOLED") - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() + @JvmField val INDIVIDUAL = of("INDIVIDUAL") + + @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + /** An enum containing [Allocation]'s known values. */ + enum class Known { + POOLED, + INDIVIDUAL, + } /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An instance of [Allocation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId + enum class Value { + POOLED, + INDIVIDUAL, + /** + * An enum member indicating that [Allocation] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + POOLED -> Value.POOLED + INDIVIDUAL -> Value.INDIVIDUAL + else -> Value._UNKNOWN + } /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + fun known(): Known = + when (this) { + POOLED -> Known.POOLED + INDIVIDUAL -> Known.INDIVIDUAL + else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") + } /** - * This field is required unless a subscription is attached via - * `subscription_config`. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun validate(): Allocation = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + known() + validated = true } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Allocation && value == other.value } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) + return other is SubscriptionConfig && + applySeatIncreaseConfig == other.applySeatIncreaseConfig && + subscriptionId == other.subscriptionId && + allocation == other.allocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applySeatIncreaseConfig, + subscriptionId, + allocation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private var validated: Boolean = false + return other is AddRecurringCredit && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + productId == other.productId && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + rateType == other.rateType && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + temporaryId == other.temporaryId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessAmount, + commitDuration, + priority, + productId, + startingAt, + applicableProductIds, + applicableProductTags, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + rateType, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + temporaryId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply - } + override fun toString() = + "AddRecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + } - creditTypeId() - unitPrice() - quantity() - validated = true - } + class AddResellerRoyalty + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val resellerType: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val awsOptions: JsonField, + private val endingBefore: JsonField, + private val fraction: JsonField, + private val gcpOptions: JsonField, + private val netsuiteResellerId: JsonField, + private val resellerContractValue: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonCreator + private constructor( + @JsonProperty("reseller_type") + @ExcludeMissing + resellerType: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("aws_options") + @ExcludeMissing + awsOptions: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("fraction") + @ExcludeMissing + fraction: JsonField = JsonMissing.of(), + @JsonProperty("gcp_options") + @ExcludeMissing + gcpOptions: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_reseller_id") + @ExcludeMissing + netsuiteResellerId: JsonField = JsonMissing.of(), + @JsonProperty("reseller_contract_value") + @ExcludeMissing + resellerContractValue: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this( + resellerType, + applicableProductIds, + applicableProductTags, + awsOptions, + endingBefore, + fraction, + gcpOptions, + netsuiteResellerId, + resellerContractValue, + startingAt, + mutableMapOf(), + ) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Must provide at least one of applicable_product_ids or applicable_product_tags. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && - additionalProperties == other.additionalProperties - } + /** + * Must provide at least one of applicable_product_ids or applicable_product_tags. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun awsOptions(): Optional = awsOptions.getOptional("aws_options") - override fun hashCode(): Int = hashCode + /** + * Use null to indicate that the existing end timestamp should be removed. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fraction(): Optional = fraction.getOptional("fraction") /** - * Defines the length of the access schedule for each created commit/credit. The value - * represents the number of units. Unit defaults to "PERIODS", where the length of a period - * is determined by the recurrence_frequency. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class CommitDuration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val value: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { + fun gcpOptions(): Optional = gcpOptions.getOptional("gcp_options") - @JsonCreator - private constructor( - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netsuiteResellerId(): Optional = + netsuiteResellerId.getOptional("netsuite_reseller_id") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): Double = value.getRequired("value") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun resellerContractValue(): Optional = + resellerContractValue.getOptional("reseller_contract_value") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAt(): Optional = startingAt.getOptional("starting_at") - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + /** + * Returns the raw JSON value of [resellerType]. + * + * Unlike [resellerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reseller_type") + @ExcludeMissing + fun _resellerType(): JsonField = resellerType - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [awsOptions]. + * + * Unlike [awsOptions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aws_options") + @ExcludeMissing + fun _awsOptions(): JsonField = awsOptions - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - companion object { + /** + * Returns the raw JSON value of [fraction]. + * + * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fraction") @ExcludeMissing fun _fraction(): JsonField = fraction - /** - * Returns a mutable builder for constructing an instance of [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [gcpOptions]. + * + * Unlike [gcpOptions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gcp_options") + @ExcludeMissing + fun _gcpOptions(): JsonField = gcpOptions - /** A builder for [CommitDuration]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [netsuiteResellerId]. + * + * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_reseller_id") + @ExcludeMissing + fun _netsuiteResellerId(): JsonField = netsuiteResellerId - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [resellerContractValue]. + * + * Unlike [resellerContractValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reseller_contract_value") + @ExcludeMissing + fun _resellerContractValue(): JsonField = resellerContractValue - @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - fun value(value: Double) = value(JsonField.of(value)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + companion object { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [AddResellerRoyalty]. + * + * The following fields are required: + * ```java + * .resellerType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [AddResellerRoyalty]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + private var resellerType: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var awsOptions: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var fraction: JsonField = JsonMissing.of() + private var gcpOptions: JsonField = JsonMissing.of() + private var netsuiteResellerId: JsonField = JsonMissing.of() + private var resellerContractValue: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmSynthetic + internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { + resellerType = addResellerRoyalty.resellerType + applicableProductIds = + addResellerRoyalty.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addResellerRoyalty.applicableProductTags.map { it.toMutableList() } + awsOptions = addResellerRoyalty.awsOptions + endingBefore = addResellerRoyalty.endingBefore + fraction = addResellerRoyalty.fraction + gcpOptions = addResellerRoyalty.gcpOptions + netsuiteResellerId = addResellerRoyalty.netsuiteResellerId + resellerContractValue = addResellerRoyalty.resellerContractValue + startingAt = addResellerRoyalty.startingAt + additionalProperties = addResellerRoyalty.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun resellerType(resellerType: ResellerType) = resellerType(JsonField.of(resellerType)) - /** - * Returns an immutable instance of [CommitDuration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, - additionalProperties.toMutableMap(), - ) + /** + * Sets [Builder.resellerType] to an arbitrary JSON value. + * + * You should usually call [Builder.resellerType] with a well-typed [ResellerType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resellerType(resellerType: JsonField) = apply { + this.resellerType = resellerType } - private var validated: Boolean = false + /** Must provide at least one of applicable_product_ids or applicable_product_tags. */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun validate(): CommitDuration = apply { - if (validated) { - return@apply - } + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - value() - unit().ifPresent { it.validate() } - validated = true + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Must provide at least one of applicable_product_ids or applicable_product_tags. */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun awsOptions(awsOptions: AwsOptions) = awsOptions(JsonField.of(awsOptions)) - companion object { + /** + * Sets [Builder.awsOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.awsOptions] with a well-typed [AwsOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun awsOptions(awsOptions: JsonField) = apply { + this.awsOptions = awsOptions + } - @JvmField val PERIODS = of("PERIODS") + /** Use null to indicate that the existing end timestamp should be removed. */ + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, - /** - * An enum member indicating that [Unit] was instantiated with an unknown value. - */ - _UNKNOWN, - } + fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN - } + /** + * Sets [Builder.fraction] to an arbitrary JSON value. + * + * You should usually call [Builder.fraction] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fraction(fraction: JsonField) = apply { this.fraction = fraction } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } + fun gcpOptions(gcpOptions: GcpOptions) = gcpOptions(JsonField.of(gcpOptions)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Sets [Builder.gcpOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.gcpOptions] with a well-typed [GcpOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gcpOptions(gcpOptions: JsonField) = apply { + this.gcpOptions = gcpOptions + } - private var validated: Boolean = false + fun netsuiteResellerId(netsuiteResellerId: String) = + netsuiteResellerId(JsonField.of(netsuiteResellerId)) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteResellerId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { + this.netsuiteResellerId = netsuiteResellerId + } - known() - validated = true - } + fun resellerContractValue(resellerContractValue: Double) = + resellerContractValue(JsonField.of(resellerContractValue)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.resellerContractValue] to an arbitrary JSON value. + * + * You should usually call [Builder.resellerContractValue] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun resellerContractValue(resellerContractValue: JsonField) = apply { + this.resellerContractValue = resellerContractValue + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - return other is Unit && value == other.value - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun hashCode() = value.hashCode() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = value.toString() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - private val hashCode: Int by lazy { Objects.hash(value, unit, additionalProperties) } + /** + * Returns an immutable instance of [AddResellerRoyalty]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resellerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddResellerRoyalty = + AddResellerRoyalty( + checkRequired("resellerType", resellerType), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + awsOptions, + endingBefore, + fraction, + gcpOptions, + netsuiteResellerId, + resellerContractValue, + startingAt, + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddResellerRoyalty = apply { + if (validated) { + return@apply + } - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + resellerType().validate() + applicableProductIds() + applicableProductTags() + awsOptions().ifPresent { it.validate() } + endingBefore() + fraction() + gcpOptions().ifPresent { it.validate() } + netsuiteResellerId() + resellerContractValue() + startingAt() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Proration @JsonCreator private constructor(private val value: JsonField) : + @JvmSynthetic + internal fun validity(): Int = + (resellerType.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (awsOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (fraction.asKnown().isPresent) 1 else 0) + + (gcpOptions.asKnown().getOrNull()?.validity() ?: 0) + + (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + + (if (resellerContractValue.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + class ResellerType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -21652,41 +25019,41 @@ private constructor( companion object { - @JvmField val NONE = of("NONE") + @JvmField val AWS = of("AWS") - @JvmField val FIRST = of("FIRST") + @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") - @JvmField val LAST = of("LAST") + @JvmField val GCP = of("GCP") - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) } - /** An enum containing [Proration]'s known values. */ + /** An enum containing [ResellerType]'s known values. */ enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, } /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Proration] can contain an unknown value in a couple of cases: + * An instance of [ResellerType] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, /** - * An enum member indicating that [Proration] was instantiated with an unknown + * An enum member indicating that [ResellerType] was instantiated with an unknown * value. */ _UNKNOWN, @@ -21701,10 +25068,10 @@ private constructor( */ fun value(): Value = when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST + AWS -> Value.AWS + AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE + GCP -> Value.GCP + GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE else -> Value._UNKNOWN } @@ -21719,11 +25086,11 @@ private constructor( */ fun known(): Known = when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + AWS -> Known.AWS + AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE + GCP -> Known.GCP + GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE + else -> throw MetronomeInvalidDataException("Unknown ResellerType: $value") } /** @@ -21752,7 +25119,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): ResellerType = apply { if (validated) { return@apply } @@ -21782,7 +25149,7 @@ private constructor( return true } - return other is Proration && value == other.value + return other is ResellerType && value == other.value } override fun hashCode() = value.hashCode() @@ -21790,260 +25157,189 @@ private constructor( override fun toString() = value.toString() } - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } + class AwsOptions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val awsAccountNumber: JsonField, + private val awsOfferId: JsonField, + private val awsPayerReferenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } + @JsonCreator + private constructor( + @JsonProperty("aws_account_number") + @ExcludeMissing + awsAccountNumber: JsonField = JsonMissing.of(), + @JsonProperty("aws_offer_id") + @ExcludeMissing + awsOfferId: JsonField = JsonMissing.of(), + @JsonProperty("aws_payer_reference_id") + @ExcludeMissing + awsPayerReferenceId: JsonField = JsonMissing.of(), + ) : this(awsAccountNumber, awsOfferId, awsPayerReferenceId, mutableMapOf()) /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - enum class Value { - COMMIT_RATE, - LIST_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown value. - */ - _UNKNOWN, - } + fun awsAccountNumber(): Optional = + awsAccountNumber.getOptional("aws_account_number") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN - } + fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + fun awsPayerReferenceId(): Optional = + awsPayerReferenceId.getOptional("aws_payer_reference_id") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [awsAccountNumber]. * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. + * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("aws_account_number") + @ExcludeMissing + fun _awsAccountNumber(): JsonField = awsAccountNumber /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns the raw JSON value of [awsOfferId]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * Unlike [awsOfferId], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun validate(): RateType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonProperty("aws_offer_id") + @ExcludeMissing + fun _awsOfferId(): JsonField = awsOfferId /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [awsPayerReferenceId]. * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aws_payer_reference_id") + @ExcludeMissing + fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId - return other is RateType && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = value.toString() - } + fun toBuilder() = Builder().from(this) - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period defined - * in the duration will correspond to this frequency. - Commits will be created aligned with - * the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** Returns a mutable builder for constructing an instance of [AwsOptions]. */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [AwsOptions]. */ + class Builder internal constructor() { - @JvmField val MONTHLY = of("MONTHLY") + private var awsAccountNumber: JsonField = JsonMissing.of() + private var awsOfferId: JsonField = JsonMissing.of() + private var awsPayerReferenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val QUARTERLY = of("QUARTERLY") + @JvmSynthetic + internal fun from(awsOptions: AwsOptions) = apply { + awsAccountNumber = awsOptions.awsAccountNumber + awsOfferId = awsOptions.awsOfferId + awsPayerReferenceId = awsOptions.awsPayerReferenceId + additionalProperties = awsOptions.additionalProperties.toMutableMap() + } - @JvmField val ANNUAL = of("ANNUAL") + fun awsAccountNumber(awsAccountNumber: String) = + awsAccountNumber(JsonField.of(awsAccountNumber)) - @JvmField val WEEKLY = of("WEEKLY") + /** + * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAccountNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun awsAccountNumber(awsAccountNumber: JsonField) = apply { + this.awsAccountNumber = awsAccountNumber + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) - } + fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** + * Sets [Builder.awsOfferId] to an arbitrary JSON value. + * + * You should usually call [Builder.awsOfferId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun awsOfferId(awsOfferId: JsonField) = apply { + this.awsOfferId = awsOfferId + } + + fun awsPayerReferenceId(awsPayerReferenceId: String) = + awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.awsPayerReferenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - _UNKNOWN, - } + fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { + this.awsPayerReferenceId = awsPayerReferenceId + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown RecurrenceFrequency: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AwsOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AwsOptions = + AwsOptions( + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -22056,12 +25352,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): AwsOptions = apply { if (validated) { return@apply } - known() + awsAccountNumber() + awsOfferId() + awsPayerReferenceId() validated = true } @@ -22079,100 +25377,88 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + + (if (awsOfferId.asKnown().isPresent) 1 else 0) + + (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is RecurrenceFrequency && value == other.value + return other is AwsOptions && + awsAccountNumber == other.awsAccountNumber && + awsOfferId == other.awsOfferId && + awsPayerReferenceId == other.awsPayerReferenceId && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "AwsOptions{awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, additionalProperties=$additionalProperties}" } - /** Attach a subscription to the recurring commit/credit. */ - class SubscriptionConfig + class GcpOptions @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val applySeatIncreaseConfig: JsonField, - private val subscriptionId: JsonField, - private val allocation: JsonField, + private val gcpAccountId: JsonField, + private val gcpOfferId: JsonField, private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - applySeatIncreaseConfig: JsonField = JsonMissing.of(), - @JsonProperty("subscription_id") - @ExcludeMissing - subscriptionId: JsonField = JsonMissing.of(), - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - ) : this(applySeatIncreaseConfig, subscriptionId, allocation, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun applySeatIncreaseConfig(): ApplySeatIncreaseConfig = - applySeatIncreaseConfig.getRequired("apply_seat_increase_config") + ) { - /** - * ID of the subscription to configure on the recurring commit/credit. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + @JsonCreator + private constructor( + @JsonProperty("gcp_account_id") + @ExcludeMissing + gcpAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gcp_offer_id") + @ExcludeMissing + gcpOfferId: JsonField = JsonMissing.of(), + ) : this(gcpAccountId, gcpOfferId, mutableMapOf()) /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun allocation(): Optional = allocation.getOptional("allocation") + fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") /** - * Returns the raw JSON value of [applySeatIncreaseConfig]. - * - * Unlike [applySeatIncreaseConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("apply_seat_increase_config") - @ExcludeMissing - fun _applySeatIncreaseConfig(): JsonField = - applySeatIncreaseConfig + fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") /** - * Returns the raw JSON value of [subscriptionId]. + * Returns the raw JSON value of [gcpAccountId]. * - * Unlike [subscriptionId], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("subscription_id") + @JsonProperty("gcp_account_id") @ExcludeMissing - fun _subscriptionId(): JsonField = subscriptionId + fun _gcpAccountId(): JsonField = gcpAccountId /** - * Returns the raw JSON value of [allocation]. + * Returns the raw JSON value of [gcpOfferId]. * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allocation") + @JsonProperty("gcp_offer_id") @ExcludeMissing - fun _allocation(): JsonField = allocation + fun _gcpOfferId(): JsonField = gcpOfferId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22188,78 +25474,48 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [SubscriptionConfig]. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [GcpOptions]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [SubscriptionConfig]. */ + /** A builder for [GcpOptions]. */ class Builder internal constructor() { - private var applySeatIncreaseConfig: JsonField? = null - private var subscriptionId: JsonField? = null - private var allocation: JsonField = JsonMissing.of() + private var gcpAccountId: JsonField = JsonMissing.of() + private var gcpOfferId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(subscriptionConfig: SubscriptionConfig) = apply { - applySeatIncreaseConfig = subscriptionConfig.applySeatIncreaseConfig - subscriptionId = subscriptionConfig.subscriptionId - allocation = subscriptionConfig.allocation - additionalProperties = subscriptionConfig.additionalProperties.toMutableMap() + internal fun from(gcpOptions: GcpOptions) = apply { + gcpAccountId = gcpOptions.gcpAccountId + gcpOfferId = gcpOptions.gcpOfferId + additionalProperties = gcpOptions.additionalProperties.toMutableMap() } - fun applySeatIncreaseConfig(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = - applySeatIncreaseConfig(JsonField.of(applySeatIncreaseConfig)) - - /** - * Sets [Builder.applySeatIncreaseConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.applySeatIncreaseConfig] with a well-typed - * [ApplySeatIncreaseConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun applySeatIncreaseConfig( - applySeatIncreaseConfig: JsonField - ) = apply { this.applySeatIncreaseConfig = applySeatIncreaseConfig } - - /** ID of the subscription to configure on the recurring commit/credit. */ - fun subscriptionId(subscriptionId: String) = - subscriptionId(JsonField.of(subscriptionId)) + fun gcpAccountId(gcpAccountId: String) = gcpAccountId(JsonField.of(gcpAccountId)) /** - * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * Sets [Builder.gcpAccountId] to an arbitrary JSON value. * - * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * You should usually call [Builder.gcpAccountId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun subscriptionId(subscriptionId: JsonField) = apply { - this.subscriptionId = subscriptionId + fun gcpAccountId(gcpAccountId: JsonField) = apply { + this.gcpAccountId = gcpAccountId } - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set - * to INDIVIDUAL, each seat in the subscription will have its own allocation. - */ - fun allocation(allocation: Allocation) = allocation(JsonField.of(allocation)) + fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) /** - * Sets [Builder.allocation] to an arbitrary JSON value. + * Sets [Builder.gcpOfferId] to an arbitrary JSON value. * - * You should usually call [Builder.allocation] with a well-typed [Allocation] value + * You should usually call [Builder.gcpOfferId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation + fun gcpOfferId(gcpOfferId: JsonField) = apply { + this.gcpOfferId = gcpOfferId } fun additionalProperties(additionalProperties: Map) = apply { @@ -22285,25 +25541,12 @@ private constructor( } /** - * Returns an immutable instance of [SubscriptionConfig]. + * Returns an immutable instance of [GcpOptions]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .applySeatIncreaseConfig() - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): SubscriptionConfig = - SubscriptionConfig( - checkRequired("applySeatIncreaseConfig", applySeatIncreaseConfig), - checkRequired("subscriptionId", subscriptionId), - allocation, - additionalProperties.toMutableMap(), - ) + fun build(): GcpOptions = + GcpOptions(gcpAccountId, gcpOfferId, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -22318,14 +25561,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): SubscriptionConfig = apply { + fun validate(): GcpOptions = apply { if (validated) { return@apply } - applySeatIncreaseConfig().validate() - subscriptionId() - allocation().ifPresent { it.validate() } + gcpAccountId() + gcpOfferId() validated = true } @@ -22345,1078 +25587,952 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (applySeatIncreaseConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionId.asKnown().isPresent) 1 else 0) + - (allocation.asKnown().getOrNull()?.validity() ?: 0) - - class ApplySeatIncreaseConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val isProrated: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of() - ) : this(isProrated, mutableMapOf()) - - /** - * Indicates whether a mid-period seat increase should be prorated. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated - - @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 - * [ApplySeatIncreaseConfig]. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ApplySeatIncreaseConfig]. */ - class Builder internal constructor() { - - private var isProrated: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(applySeatIncreaseConfig: ApplySeatIncreaseConfig) = apply { - isProrated = applySeatIncreaseConfig.isProrated - additionalProperties = - applySeatIncreaseConfig.additionalProperties.toMutableMap() - } - - /** Indicates whether a mid-period seat increase should be prorated. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - - /** - * Sets [Builder.isProrated] to an arbitrary JSON value. - * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + (if (gcpAccountId.asKnown().isPresent) 1 else 0) + + (if (gcpOfferId.asKnown().isPresent) 1 else 0) - /** - * Returns an immutable instance of [ApplySeatIncreaseConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .isProrated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ApplySeatIncreaseConfig = - ApplySeatIncreaseConfig( - checkRequired("isProrated", isProrated), - additionalProperties.toMutableMap(), - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private var validated: Boolean = false + return other is GcpOptions && + gcpAccountId == other.gcpAccountId && + gcpOfferId == other.gcpOfferId && + additionalProperties == other.additionalProperties + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ApplySeatIncreaseConfig = apply { - if (validated) { - return@apply - } + private val hashCode: Int by lazy { + Objects.hash(gcpAccountId, gcpOfferId, additionalProperties) + } - isProrated() - validated = true - } + override fun hashCode(): Int = hashCode - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun toString() = + "GcpOptions{gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, additionalProperties=$additionalProperties}" + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (isProrated.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + return other is AddResellerRoyalty && + resellerType == other.resellerType && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + awsOptions == other.awsOptions && + endingBefore == other.endingBefore && + fraction == other.fraction && + gcpOptions == other.gcpOptions && + netsuiteResellerId == other.netsuiteResellerId && + resellerContractValue == other.resellerContractValue && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - return other is ApplySeatIncreaseConfig && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } + private val hashCode: Int by lazy { + Objects.hash( + resellerType, + applicableProductIds, + applicableProductTags, + awsOptions, + endingBefore, + fraction, + gcpOptions, + netsuiteResellerId, + resellerContractValue, + startingAt, + additionalProperties, + ) + } - private val hashCode: Int by lazy { Objects.hash(isProrated, additionalProperties) } + override fun hashCode(): Int = hashCode - override fun hashCode(): Int = hashCode + override fun toString() = + "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsOptions=$awsOptions, endingBefore=$endingBefore, fraction=$fraction, gcpOptions=$gcpOptions, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - override fun toString() = - "ApplySeatIncreaseConfig{isProrated=$isProrated, additionalProperties=$additionalProperties}" - } + /** + * Update the revenue system configuration on the contract. Currently only supports adding a + * revenue system configuration to a contract that does not already have one. + */ + class AddRevenueSystemConfigurationUpdate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val revenueSystemConfiguration: JsonField, + private val schedule: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * If set to POOLED, allocation added per seat is pooled across the account. If set to - * INDIVIDUAL, each seat in the subscription will have its own allocation. - */ - class Allocation - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JsonCreator + private constructor( + @JsonProperty("revenue_system_configuration") + @ExcludeMissing + revenueSystemConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + ) : this(revenueSystemConfiguration, schedule, mutableMapOf()) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun revenueSystemConfiguration(): RevenueSystemConfiguration = + revenueSystemConfiguration.getRequired("revenue_system_configuration") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") - @JvmField val POOLED = of("POOLED") + /** + * Returns the raw JSON value of [revenueSystemConfiguration]. + * + * Unlike [revenueSystemConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("revenue_system_configuration") + @ExcludeMissing + fun _revenueSystemConfiguration(): JsonField = + revenueSystemConfiguration - @JvmField val INDIVIDUAL = of("INDIVIDUAL") + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schedule") @ExcludeMissing fun _schedule(): JsonField = schedule - @JvmStatic fun of(value: String) = Allocation(JsonField.of(value)) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** An enum containing [Allocation]'s known values. */ - enum class Known { - POOLED, - INDIVIDUAL, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * An enum containing [Allocation]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Allocation] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - POOLED, - INDIVIDUAL, - /** - * An enum member indicating that [Allocation] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun toBuilder() = Builder().from(this) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - POOLED -> Value.POOLED - INDIVIDUAL -> Value.INDIVIDUAL - else -> Value._UNKNOWN - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - POOLED -> Known.POOLED - INDIVIDUAL -> Known.INDIVIDUAL - else -> throw MetronomeInvalidDataException("Unknown Allocation: $value") - } + /** + * Returns a mutable builder for constructing an instance of + * [AddRevenueSystemConfigurationUpdate]. + * + * The following fields are required: + * ```java + * .revenueSystemConfiguration() + * .schedule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** A builder for [AddRevenueSystemConfigurationUpdate]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var revenueSystemConfiguration: JsonField? = null + private var schedule: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Allocation = apply { - if (validated) { - return@apply - } + @JvmSynthetic + internal fun from( + addRevenueSystemConfigurationUpdate: AddRevenueSystemConfigurationUpdate + ) = apply { + revenueSystemConfiguration = + addRevenueSystemConfigurationUpdate.revenueSystemConfiguration + schedule = addRevenueSystemConfigurationUpdate.schedule + additionalProperties = + addRevenueSystemConfigurationUpdate.additionalProperties.toMutableMap() + } - known() - validated = true - } + fun revenueSystemConfiguration(revenueSystemConfiguration: RevenueSystemConfiguration) = + revenueSystemConfiguration(JsonField.of(revenueSystemConfiguration)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.revenueSystemConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.revenueSystemConfiguration] with a well-typed + * [RevenueSystemConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun revenueSystemConfiguration( + revenueSystemConfiguration: JsonField + ) = apply { this.revenueSystemConfiguration = revenueSystemConfiguration } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - return other is Allocation && value == other.value - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun hashCode() = value.hashCode() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = value.toString() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - return other is SubscriptionConfig && - applySeatIncreaseConfig == other.applySeatIncreaseConfig && - subscriptionId == other.subscriptionId && - allocation == other.allocation && - additionalProperties == other.additionalProperties + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - private val hashCode: Int by lazy { - Objects.hash( - applySeatIncreaseConfig, - subscriptionId, - allocation, - additionalProperties, + /** + * Returns an immutable instance of [AddRevenueSystemConfigurationUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .revenueSystemConfiguration() + * .schedule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddRevenueSystemConfigurationUpdate = + AddRevenueSystemConfigurationUpdate( + checkRequired("revenueSystemConfiguration", revenueSystemConfiguration), + checkRequired("schedule", schedule), + additionalProperties.toMutableMap(), ) - } + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "SubscriptionConfig{applySeatIncreaseConfig=$applySeatIncreaseConfig, subscriptionId=$subscriptionId, allocation=$allocation, additionalProperties=$additionalProperties}" + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddRevenueSystemConfigurationUpdate = apply { + if (validated) { + return@apply + } + + revenueSystemConfiguration().validate() + schedule().validate() + validated = true } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - return other is AddRecurringCredit && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - productId == other.productId && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - rateType == other.rateType && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - temporaryId == other.temporaryId && - additionalProperties == other.additionalProperties - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (revenueSystemConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) - private val hashCode: Int by lazy { - Objects.hash( - accessAmount, - commitDuration, - priority, - productId, - startingAt, - applicableProductIds, - applicableProductTags, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - rateType, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - temporaryId, - additionalProperties, - ) - } + class RevenueSystemConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val deliveryMethod: JsonField, + private val provider: JsonField, + private val revenueSystemConfigurationId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("delivery_method") + @ExcludeMissing + deliveryMethod: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + @JsonProperty("revenue_system_configuration_id") + @ExcludeMissing + revenueSystemConfigurationId: JsonField = JsonMissing.of(), + ) : this(deliveryMethod, provider, revenueSystemConfigurationId, mutableMapOf()) - override fun toString() = - "AddRecurringCredit{accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, productId=$productId, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, rateType=$rateType, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun deliveryMethod(): Optional = + deliveryMethod.getOptional("delivery_method") + + /** + * The revenue system provider type. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") - class AddResellerRoyalty - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val resellerType: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val awsOptions: JsonField, - private val endingBefore: JsonField, - private val fraction: JsonField, - private val gcpOptions: JsonField, - private val netsuiteResellerId: JsonField, - private val resellerContractValue: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun revenueSystemConfigurationId(): Optional = + revenueSystemConfigurationId.getOptional("revenue_system_configuration_id") - @JsonCreator - private constructor( - @JsonProperty("reseller_type") - @ExcludeMissing - resellerType: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("aws_options") - @ExcludeMissing - awsOptions: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("fraction") - @ExcludeMissing - fraction: JsonField = JsonMissing.of(), - @JsonProperty("gcp_options") + /** + * Returns the raw JSON value of [deliveryMethod]. + * + * Unlike [deliveryMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivery_method") @ExcludeMissing - gcpOptions: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_reseller_id") + fun _deliveryMethod(): JsonField = deliveryMethod + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider") @ExcludeMissing - netsuiteResellerId: JsonField = JsonMissing.of(), - @JsonProperty("reseller_contract_value") + fun _provider(): JsonField = provider + + /** + * Returns the raw JSON value of [revenueSystemConfigurationId]. + * + * Unlike [revenueSystemConfigurationId], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("revenue_system_configuration_id") @ExcludeMissing - resellerContractValue: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + fun _revenueSystemConfigurationId(): JsonField = revenueSystemConfigurationId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this( - resellerType, - applicableProductIds, - applicableProductTags, - awsOptions, - endingBefore, - fraction, - gcpOptions, - netsuiteResellerId, - resellerContractValue, - startingAt, - mutableMapOf(), - ) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") + fun toBuilder() = Builder().from(this) - /** - * Must provide at least one of applicable_product_ids or applicable_product_tags. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + companion object { - /** - * Must provide at least one of applicable_product_ids or applicable_product_tags. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * Returns a mutable builder for constructing an instance of + * [RevenueSystemConfiguration]. + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun awsOptions(): Optional = awsOptions.getOptional("aws_options") + /** A builder for [RevenueSystemConfiguration]. */ + class Builder internal constructor() { - /** - * Use null to indicate that the existing end timestamp should be removed. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + private var deliveryMethod: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var revenueSystemConfigurationId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fraction(): Optional = fraction.getOptional("fraction") + @JvmSynthetic + internal fun from(revenueSystemConfiguration: RevenueSystemConfiguration) = apply { + deliveryMethod = revenueSystemConfiguration.deliveryMethod + provider = revenueSystemConfiguration.provider + revenueSystemConfigurationId = + revenueSystemConfiguration.revenueSystemConfigurationId + additionalProperties = + revenueSystemConfiguration.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun gcpOptions(): Optional = gcpOptions.getOptional("gcp_options") + fun deliveryMethod(deliveryMethod: DeliveryMethod) = + deliveryMethod(JsonField.of(deliveryMethod)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netsuiteResellerId(): Optional = - netsuiteResellerId.getOptional("netsuite_reseller_id") + /** + * Sets [Builder.deliveryMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryMethod] with a well-typed + * [DeliveryMethod] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun deliveryMethod(deliveryMethod: JsonField) = apply { + this.deliveryMethod = deliveryMethod + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun resellerContractValue(): Optional = - resellerContractValue.getOptional("reseller_contract_value") + /** The revenue system provider type. */ + fun provider(provider: Provider) = provider(JsonField.of(provider)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [Provider] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun revenueSystemConfigurationId(revenueSystemConfigurationId: String) = + revenueSystemConfigurationId(JsonField.of(revenueSystemConfigurationId)) + + /** + * Sets [Builder.revenueSystemConfigurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.revenueSystemConfigurationId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun revenueSystemConfigurationId(revenueSystemConfigurationId: JsonField) = + apply { + this.revenueSystemConfigurationId = revenueSystemConfigurationId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RevenueSystemConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RevenueSystemConfiguration = + RevenueSystemConfiguration( + deliveryMethod, + provider, + revenueSystemConfigurationId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [resellerType]. - * - * Unlike [resellerType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reseller_type") - @ExcludeMissing - fun _resellerType(): JsonField = resellerType + private var validated: Boolean = false - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RevenueSystemConfiguration = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + deliveryMethod().ifPresent { it.validate() } + provider().ifPresent { it.validate() } + revenueSystemConfigurationId() + validated = true + } - /** - * Returns the raw JSON value of [awsOptions]. - * - * Unlike [awsOptions], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("aws_options") - @ExcludeMissing - fun _awsOptions(): JsonField = awsOptions + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (deliveryMethod.asKnown().getOrNull()?.validity() ?: 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + (if (revenueSystemConfigurationId.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [fraction]. - * - * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fraction") @ExcludeMissing fun _fraction(): JsonField = fraction + class DeliveryMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [gcpOptions]. - * - * Unlike [gcpOptions], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("gcp_options") - @ExcludeMissing - fun _gcpOptions(): JsonField = gcpOptions + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns the raw JSON value of [netsuiteResellerId]. - * - * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_reseller_id") - @ExcludeMissing - fun _netsuiteResellerId(): JsonField = netsuiteResellerId + companion object { - /** - * Returns the raw JSON value of [resellerContractValue]. - * - * Unlike [resellerContractValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reseller_contract_value") - @ExcludeMissing - fun _resellerContractValue(): JsonField = resellerContractValue + @JvmField val DIRECT_TO_BILLING_PROVIDER = of("direct_to_billing_provider") - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JvmField val AWS_SQS = of("aws_sqs") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val TACKLE = of("tackle") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val AWS_SNS = of("aws_sns") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = DeliveryMethod(JsonField.of(value)) + } - companion object { + /** An enum containing [DeliveryMethod]'s known values. */ + enum class Known { + DIRECT_TO_BILLING_PROVIDER, + AWS_SQS, + TACKLE, + AWS_SNS, + } - /** - * Returns a mutable builder for constructing an instance of [AddResellerRoyalty]. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * An enum containing [DeliveryMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DeliveryMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIRECT_TO_BILLING_PROVIDER, + AWS_SQS, + TACKLE, + AWS_SNS, + /** + * An enum member indicating that [DeliveryMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** A builder for [AddResellerRoyalty]. */ - class Builder internal constructor() { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIRECT_TO_BILLING_PROVIDER -> Value.DIRECT_TO_BILLING_PROVIDER + AWS_SQS -> Value.AWS_SQS + TACKLE -> Value.TACKLE + AWS_SNS -> Value.AWS_SNS + else -> Value._UNKNOWN + } - private var resellerType: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var awsOptions: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var fraction: JsonField = JsonMissing.of() - private var gcpOptions: JsonField = JsonMissing.of() - private var netsuiteResellerId: JsonField = JsonMissing.of() - private var resellerContractValue: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DIRECT_TO_BILLING_PROVIDER -> Known.DIRECT_TO_BILLING_PROVIDER + AWS_SQS -> Known.AWS_SQS + TACKLE -> Known.TACKLE + AWS_SNS -> Known.AWS_SNS + else -> + throw MetronomeInvalidDataException("Unknown DeliveryMethod: $value") + } - @JvmSynthetic - internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { - resellerType = addResellerRoyalty.resellerType - applicableProductIds = - addResellerRoyalty.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addResellerRoyalty.applicableProductTags.map { it.toMutableList() } - awsOptions = addResellerRoyalty.awsOptions - endingBefore = addResellerRoyalty.endingBefore - fraction = addResellerRoyalty.fraction - gcpOptions = addResellerRoyalty.gcpOptions - netsuiteResellerId = addResellerRoyalty.netsuiteResellerId - resellerContractValue = addResellerRoyalty.resellerContractValue - startingAt = addResellerRoyalty.startingAt - additionalProperties = addResellerRoyalty.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun resellerType(resellerType: ResellerType) = resellerType(JsonField.of(resellerType)) + private var validated: Boolean = false - /** - * Sets [Builder.resellerType] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerType] with a well-typed [ResellerType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun resellerType(resellerType: JsonField) = apply { - this.resellerType = resellerType - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DeliveryMethod = apply { + if (validated) { + return@apply + } - /** Must provide at least one of applicable_product_ids or applicable_product_tags. */ - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + known() + validated = true + } - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - /** Must provide at least one of applicable_product_ids or applicable_product_tags. */ - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + return other is DeliveryMethod && value == other.value + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + override fun hashCode() = value.hashCode() - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } + override fun toString() = value.toString() } - fun awsOptions(awsOptions: AwsOptions) = awsOptions(JsonField.of(awsOptions)) + /** The revenue system provider type. */ + class Provider @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Sets [Builder.awsOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.awsOptions] with a well-typed [AwsOptions] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun awsOptions(awsOptions: JsonField) = apply { - this.awsOptions = awsOptions - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Use null to indicate that the existing end timestamp should be removed. */ - fun endingBefore(endingBefore: OffsetDateTime?) = - endingBefore(JsonField.ofNullable(endingBefore)) + companion object { - /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ - fun endingBefore(endingBefore: Optional) = - endingBefore(endingBefore.getOrNull()) + @JvmField val NETSUITE = of("netsuite") - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + @JvmStatic fun of(value: String) = Provider(JsonField.of(value)) + } - fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) + /** An enum containing [Provider]'s known values. */ + enum class Known { + NETSUITE + } - /** - * Sets [Builder.fraction] to an arbitrary JSON value. - * - * You should usually call [Builder.fraction] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fraction(fraction: JsonField) = apply { this.fraction = fraction } + /** + * An enum containing [Provider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Provider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NETSUITE, + /** + * An enum member indicating that [Provider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun gcpOptions(gcpOptions: GcpOptions) = gcpOptions(JsonField.of(gcpOptions)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NETSUITE -> Value.NETSUITE + else -> Value._UNKNOWN + } - /** - * Sets [Builder.gcpOptions] to an arbitrary JSON value. - * - * You should usually call [Builder.gcpOptions] with a well-typed [GcpOptions] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun gcpOptions(gcpOptions: JsonField) = apply { - this.gcpOptions = gcpOptions - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NETSUITE -> Known.NETSUITE + else -> throw MetronomeInvalidDataException("Unknown Provider: $value") + } - fun netsuiteResellerId(netsuiteResellerId: String) = - netsuiteResellerId(JsonField.of(netsuiteResellerId)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteResellerId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { - this.netsuiteResellerId = netsuiteResellerId - } + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Provider = apply { + if (validated) { + return@apply + } - fun resellerContractValue(resellerContractValue: Double) = - resellerContractValue(JsonField.of(resellerContractValue)) + known() + validated = true + } - /** - * Sets [Builder.resellerContractValue] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerContractValue] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun resellerContractValue(resellerContractValue: JsonField) = apply { - this.resellerContractValue = resellerContractValue - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + return other is Provider && value == other.value + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode() = value.hashCode() - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + override fun toString() = value.toString() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + return other is RevenueSystemConfiguration && + deliveryMethod == other.deliveryMethod && + provider == other.provider && + revenueSystemConfigurationId == other.revenueSystemConfigurationId && + additionalProperties == other.additionalProperties } - /** - * Returns an immutable instance of [AddResellerRoyalty]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddResellerRoyalty = - AddResellerRoyalty( - checkRequired("resellerType", resellerType), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - awsOptions, - endingBefore, - fraction, - gcpOptions, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties.toMutableMap(), + private val hashCode: Int by lazy { + Objects.hash( + deliveryMethod, + provider, + revenueSystemConfigurationId, + additionalProperties, ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddResellerRoyalty = apply { - if (validated) { - return@apply } - resellerType().validate() - applicableProductIds() - applicableProductTags() - awsOptions().ifPresent { it.validate() } - endingBefore() - fraction() - gcpOptions().ifPresent { it.validate() } - netsuiteResellerId() - resellerContractValue() - startingAt() - validated = true - } + override fun hashCode(): Int = hashCode - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun toString() = + "RevenueSystemConfiguration{deliveryMethod=$deliveryMethod, provider=$provider, revenueSystemConfigurationId=$revenueSystemConfigurationId, additionalProperties=$additionalProperties}" + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (resellerType.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (awsOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (fraction.asKnown().isPresent) 1 else 0) + - (gcpOptions.asKnown().getOrNull()?.validity() ?: 0) + - (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + - (if (resellerContractValue.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + class Schedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val effectiveAt: JsonField, + private val additionalProperties: MutableMap, + ) { - class ResellerType @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JsonCreator + private constructor( + @JsonProperty("effective_at") + @ExcludeMissing + effectiveAt: JsonField = JsonMissing.of() + ) : this(effectiveAt, mutableMapOf()) /** - * Returns this class instance's raw value. + * When the revenue system configuration update will take effect. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun effectiveAt(): EffectiveAt = effectiveAt.getRequired("effective_at") - companion object { + /** + * Returns the raw JSON value of [effectiveAt]. + * + * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_at") + @ExcludeMissing + fun _effectiveAt(): JsonField = effectiveAt - @JvmField val AWS = of("AWS") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val GCP = of("GCP") + fun toBuilder() = Builder().from(this) - @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") + companion object { - @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of [Schedule]. + * + * The following fields are required: + * ```java + * .effectiveAt() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [ResellerType]'s known values. */ - enum class Known { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, - } + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var effectiveAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + effectiveAt = schedule.effectiveAt + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + /** When the revenue system configuration update will take effect. */ + fun effectiveAt(effectiveAt: EffectiveAt) = effectiveAt(JsonField.of(effectiveAt)) - /** - * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ResellerType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, /** - * An enum member indicating that [ResellerType] was instantiated with an unknown - * value. + * Sets [Builder.effectiveAt] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveAt] with a well-typed [EffectiveAt] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - _UNKNOWN, - } + fun effectiveAt(effectiveAt: JsonField) = apply { + this.effectiveAt = effectiveAt + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AWS -> Value.AWS - AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE - GCP -> Value.GCP - GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AWS -> Known.AWS - AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE - GCP -> Known.GCP - GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE - else -> throw MetronomeInvalidDataException("Unknown ResellerType: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .effectiveAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schedule = + Schedule( + checkRequired("effectiveAt", effectiveAt), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -23429,12 +26545,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ResellerType = apply { + fun validate(): Schedule = apply { if (validated) { return@apply } - known() + effectiveAt().validate() validated = true } @@ -23452,323 +26568,595 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = (effectiveAt.asKnown().getOrNull()?.validity() ?: 0) + + /** When the revenue system configuration update will take effect. */ + class EffectiveAt + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val START_OF_CURRENT_PERIOD = of("START_OF_CURRENT_PERIOD") + + @JvmStatic fun of(value: String) = EffectiveAt(JsonField.of(value)) + } + + /** An enum containing [EffectiveAt]'s known values. */ + enum class Known { + START_OF_CURRENT_PERIOD + } + + /** + * An enum containing [EffectiveAt]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EffectiveAt] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + START_OF_CURRENT_PERIOD, + /** + * An enum member indicating that [EffectiveAt] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + START_OF_CURRENT_PERIOD -> Value.START_OF_CURRENT_PERIOD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + START_OF_CURRENT_PERIOD -> Known.START_OF_CURRENT_PERIOD + else -> throw MetronomeInvalidDataException("Unknown EffectiveAt: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): EffectiveAt = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EffectiveAt && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ResellerType && value == other.value + return other is Schedule && + effectiveAt == other.effectiveAt && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(effectiveAt, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schedule{effectiveAt=$effectiveAt, additionalProperties=$additionalProperties}" } - class AwsOptions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val awsAccountNumber: JsonField, - private val awsOfferId: JsonField, - private val awsPayerReferenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddRevenueSystemConfigurationUpdate && + revenueSystemConfiguration == other.revenueSystemConfiguration && + schedule == other.schedule && + additionalProperties == other.additionalProperties + } - @JsonCreator - private constructor( - @JsonProperty("aws_account_number") - @ExcludeMissing - awsAccountNumber: JsonField = JsonMissing.of(), - @JsonProperty("aws_offer_id") - @ExcludeMissing - awsOfferId: JsonField = JsonMissing.of(), - @JsonProperty("aws_payer_reference_id") - @ExcludeMissing - awsPayerReferenceId: JsonField = JsonMissing.of(), - ) : this(awsAccountNumber, awsOfferId, awsPayerReferenceId, mutableMapOf()) + private val hashCode: Int by lazy { + Objects.hash(revenueSystemConfiguration, schedule, additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsAccountNumber(): Optional = - awsAccountNumber.getOptional("aws_account_number") + override fun hashCode(): Int = hashCode - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") + override fun toString() = + "AddRevenueSystemConfigurationUpdate{revenueSystemConfiguration=$revenueSystemConfiguration, schedule=$schedule, additionalProperties=$additionalProperties}" + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsPayerReferenceId(): Optional = - awsPayerReferenceId.getOptional("aws_payer_reference_id") + class AddScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val productId: JsonField, + private val schedule: JsonField, + private val customFields: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [awsAccountNumber]. - * - * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_account_number") + @JsonCreator + private constructor( + @JsonProperty("product_id") @ExcludeMissing - fun _awsAccountNumber(): JsonField = awsAccountNumber - - /** - * Returns the raw JSON value of [awsOfferId]. - * - * Unlike [awsOfferId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("aws_offer_id") + productId: JsonField = JsonMissing.of(), + @JsonProperty("schedule") @ExcludeMissing - fun _awsOfferId(): JsonField = awsOfferId - - /** - * Returns the raw JSON value of [awsPayerReferenceId]. - * - * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_payer_reference_id") + schedule: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") @ExcludeMissing - fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId + customFields: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + ) : this(productId, schedule, customFields, name, netsuiteSalesOrderId, mutableMapOf()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun productId(): String = productId.getRequired("product_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Must provide either schedule_items or recurring_schedule. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun schedule(): Schedule = schedule.getRequired("schedule") - fun toBuilder() = Builder().from(this) + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") - companion object { + /** + * displayed on invoices + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - /** Returns a mutable builder for constructing an instance of [AwsOptions]. */ - @JvmStatic fun builder() = Builder() - } + /** + * This field's availability is dependent on your client's configuration. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - /** A builder for [AwsOptions]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId - private var awsAccountNumber: JsonField = JsonMissing.of() - private var awsOfferId: JsonField = JsonMissing.of() - private var awsPayerReferenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schedule") @ExcludeMissing fun _schedule(): JsonField = schedule - @JvmSynthetic - internal fun from(awsOptions: AwsOptions) = apply { - awsAccountNumber = awsOptions.awsAccountNumber - awsOfferId = awsOptions.awsOfferId - awsPayerReferenceId = awsOptions.awsPayerReferenceId - additionalProperties = awsOptions.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - fun awsAccountNumber(awsAccountNumber: String) = - awsAccountNumber(JsonField.of(awsAccountNumber)) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.awsAccountNumber] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun awsAccountNumber(awsAccountNumber: JsonField) = apply { - this.awsAccountNumber = awsAccountNumber - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.awsOfferId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsOfferId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun awsOfferId(awsOfferId: JsonField) = apply { - this.awsOfferId = awsOfferId - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun awsPayerReferenceId(awsPayerReferenceId: String) = - awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsPayerReferenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { - this.awsPayerReferenceId = awsPayerReferenceId - } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AddScheduledCharge]. + * + * The following fields are required: + * ```java + * .productId() + * .schedule() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddScheduledCharge]. */ + class Builder internal constructor() { + + private var productId: JsonField? = null + private var schedule: JsonField? = null + private var customFields: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addScheduledCharge: AddScheduledCharge) = apply { + productId = addScheduledCharge.productId + schedule = addScheduledCharge.schedule + customFields = addScheduledCharge.customFields + name = addScheduledCharge.name + netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId + additionalProperties = addScheduledCharge.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun productId(productId: String) = productId(JsonField.of(productId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** Must provide either schedule_items or recurring_schedule. */ + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) - /** - * Returns an immutable instance of [AwsOptions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AwsOptions = - AwsOptions( - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - additionalProperties.toMutableMap(), - ) + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields } - private var validated: Boolean = false + /** displayed on invoices */ + fun name(name: String) = name(JsonField.of(name)) /** - * Validates that the types of all values in this object match their expected types - * recursively. + * Sets [Builder.name] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** This field's availability is dependent on your client's configuration. */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun validate(): AwsOptions = apply { - if (validated) { - return@apply - } + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - awsAccountNumber() - awsOfferId() - awsPayerReferenceId() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AddScheduledCharge]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .productId() + * .schedule() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + - (if (awsOfferId.asKnown().isPresent) 1 else 0) + - (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) + fun build(): AddScheduledCharge = + AddScheduledCharge( + checkRequired("productId", productId), + checkRequired("schedule", schedule), + customFields, + name, + netsuiteSalesOrderId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is AwsOptions && - awsAccountNumber == other.awsAccountNumber && - awsOfferId == other.awsOfferId && - awsPayerReferenceId == other.awsPayerReferenceId && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddScheduledCharge = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - additionalProperties, - ) - } + productId() + schedule().validate() + customFields().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "AwsOptions{awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (productId.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) - class GcpOptions + /** Must provide either schedule_items or recurring_schedule. */ + class Schedule @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val gcpAccountId: JsonField, - private val gcpOfferId: JsonField, + private val creditTypeId: JsonField, + private val doNotInvoice: JsonField, + private val recurringSchedule: JsonField, + private val scheduleItems: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("gcp_account_id") + @JsonProperty("credit_type_id") @ExcludeMissing - gcpAccountId: JsonField = JsonMissing.of(), - @JsonProperty("gcp_offer_id") + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("do_not_invoice") @ExcludeMissing - gcpOfferId: JsonField = JsonMissing.of(), - ) : this(gcpAccountId, gcpOfferId, mutableMapOf()) + doNotInvoice: JsonField = JsonMissing.of(), + @JsonProperty("recurring_schedule") + @ExcludeMissing + recurringSchedule: JsonField = JsonMissing.of(), + @JsonProperty("schedule_items") + @ExcludeMissing + scheduleItems: JsonField> = JsonMissing.of(), + ) : this(creditTypeId, doNotInvoice, recurringSchedule, scheduleItems, mutableMapOf()) + + /** + * Defaults to USD (cents) if not passed. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creditTypeId(): Optional = creditTypeId.getOptional("credit_type_id") + + /** + * This field is only applicable to commit invoice schedules. If true, this schedule + * will not generate an invoice. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun doNotInvoice(): Optional = doNotInvoice.getOptional("do_not_invoice") /** + * Enter the unit price and quantity for the charge or instead only send the amount. If + * amount is sent, the unit price is assumed to be the amount and quantity is inferred + * to be 1. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") + fun recurringSchedule(): Optional = + recurringSchedule.getOptional("recurring_schedule") /** + * Either provide amount or provide both unit_price and quantity. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") + fun scheduleItems(): Optional> = + scheduleItems.getOptional("schedule_items") /** - * Returns the raw JSON value of [gcpAccountId]. + * Returns the raw JSON value of [creditTypeId]. * - * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an unexpected + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("gcp_account_id") + @JsonProperty("credit_type_id") @ExcludeMissing - fun _gcpAccountId(): JsonField = gcpAccountId + fun _creditTypeId(): JsonField = creditTypeId /** - * Returns the raw JSON value of [gcpOfferId]. + * Returns the raw JSON value of [doNotInvoice]. * - * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an unexpected + * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("gcp_offer_id") + @JsonProperty("do_not_invoice") @ExcludeMissing - fun _gcpOfferId(): JsonField = gcpOfferId + fun _doNotInvoice(): JsonField = doNotInvoice + + /** + * Returns the raw JSON value of [recurringSchedule]. + * + * Unlike [recurringSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurring_schedule") + @ExcludeMissing + fun _recurringSchedule(): JsonField = recurringSchedule + + /** + * Returns the raw JSON value of [scheduleItems]. + * + * Unlike [scheduleItems], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule_items") + @ExcludeMissing + fun _scheduleItems(): JsonField> = scheduleItems @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23784,1190 +27172,1235 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [GcpOptions]. */ + /** Returns a mutable builder for constructing an instance of [Schedule]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [GcpOptions]. */ + /** A builder for [Schedule]. */ class Builder internal constructor() { - private var gcpAccountId: JsonField = JsonMissing.of() - private var gcpOfferId: JsonField = JsonMissing.of() + private var creditTypeId: JsonField = JsonMissing.of() + private var doNotInvoice: JsonField = JsonMissing.of() + private var recurringSchedule: JsonField = JsonMissing.of() + private var scheduleItems: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gcpOptions: GcpOptions) = apply { - gcpAccountId = gcpOptions.gcpAccountId - gcpOfferId = gcpOptions.gcpOfferId - additionalProperties = gcpOptions.additionalProperties.toMutableMap() + internal fun from(schedule: Schedule) = apply { + creditTypeId = schedule.creditTypeId + doNotInvoice = schedule.doNotInvoice + recurringSchedule = schedule.recurringSchedule + scheduleItems = schedule.scheduleItems.map { it.toMutableList() } + additionalProperties = schedule.additionalProperties.toMutableMap() } - fun gcpAccountId(gcpAccountId: String) = gcpAccountId(JsonField.of(gcpAccountId)) + /** Defaults to USD (cents) if not passed. */ + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) /** - * Sets [Builder.gcpAccountId] to an arbitrary JSON value. + * Sets [Builder.creditTypeId] to an arbitrary JSON value. * - * You should usually call [Builder.gcpAccountId] with a well-typed [String] value + * You should usually call [Builder.creditTypeId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun gcpAccountId(gcpAccountId: JsonField) = apply { - this.gcpAccountId = gcpAccountId + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId } - fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) + /** + * This field is only applicable to commit invoice schedules. If true, this schedule + * will not generate an invoice. + */ + fun doNotInvoice(doNotInvoice: Boolean) = doNotInvoice(JsonField.of(doNotInvoice)) /** - * Sets [Builder.gcpOfferId] to an arbitrary JSON value. + * Sets [Builder.doNotInvoice] to an arbitrary JSON value. * - * You should usually call [Builder.gcpOfferId] with a well-typed [String] value + * You should usually call [Builder.doNotInvoice] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun gcpOfferId(gcpOfferId: JsonField) = apply { - this.gcpOfferId = gcpOfferId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun doNotInvoice(doNotInvoice: JsonField) = apply { + this.doNotInvoice = doNotInvoice } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Enter the unit price and quantity for the charge or instead only send the amount. + * If amount is sent, the unit price is assumed to be the amount and quantity is + * inferred to be 1. + */ + fun recurringSchedule(recurringSchedule: RecurringSchedule) = + recurringSchedule(JsonField.of(recurringSchedule)) /** - * Returns an immutable instance of [GcpOptions]. + * Sets [Builder.recurringSchedule] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * You should usually call [Builder.recurringSchedule] with a well-typed + * [RecurringSchedule] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun build(): GcpOptions = - GcpOptions(gcpAccountId, gcpOfferId, 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): GcpOptions = apply { - if (validated) { - return@apply - } - - gcpAccountId() - gcpOfferId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (gcpAccountId.asKnown().isPresent) 1 else 0) + - (if (gcpOfferId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun recurringSchedule(recurringSchedule: JsonField) = apply { + this.recurringSchedule = recurringSchedule } - return other is GcpOptions && - gcpAccountId == other.gcpAccountId && - gcpOfferId == other.gcpOfferId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(gcpAccountId, gcpOfferId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GcpOptions{gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddResellerRoyalty && - resellerType == other.resellerType && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - awsOptions == other.awsOptions && - endingBefore == other.endingBefore && - fraction == other.fraction && - gcpOptions == other.gcpOptions && - netsuiteResellerId == other.netsuiteResellerId && - resellerContractValue == other.resellerContractValue && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - resellerType, - applicableProductIds, - applicableProductTags, - awsOptions, - endingBefore, - fraction, - gcpOptions, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsOptions=$awsOptions, endingBefore=$endingBefore, fraction=$fraction, gcpOptions=$gcpOptions, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } - - /** - * Update the revenue system configuration on the contract. Currently only supports adding a - * revenue system configuration to a contract that does not already have one. - */ - class AddRevenueSystemConfigurationUpdate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val revenueSystemConfiguration: JsonField, - private val schedule: JsonField, - private val additionalProperties: MutableMap, - ) { + /** Either provide amount or provide both unit_price and quantity. */ + fun scheduleItems(scheduleItems: List) = + scheduleItems(JsonField.of(scheduleItems)) - @JsonCreator - private constructor( - @JsonProperty("revenue_system_configuration") - @ExcludeMissing - revenueSystemConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - ) : this(revenueSystemConfiguration, schedule, mutableMapOf()) + /** + * Sets [Builder.scheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduleItems(scheduleItems: JsonField>) = apply { + this.scheduleItems = scheduleItems.map { it.toMutableList() } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun revenueSystemConfiguration(): RevenueSystemConfiguration = - revenueSystemConfiguration.getRequired("revenue_system_configuration") + /** + * Adds a single [ScheduleItem] to [scheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScheduleItem(scheduleItem: ScheduleItem) = apply { + scheduleItems = + (scheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleItems", it).add(scheduleItem) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun schedule(): Schedule = schedule.getRequired("schedule") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [revenueSystemConfiguration]. - * - * Unlike [revenueSystemConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("revenue_system_configuration") - @ExcludeMissing - fun _revenueSystemConfiguration(): JsonField = - revenueSystemConfiguration + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [schedule]. - * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("schedule") @ExcludeMissing fun _schedule(): JsonField = schedule + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Schedule = + Schedule( + creditTypeId, + doNotInvoice, + recurringSchedule, + (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of - * [AddRevenueSystemConfigurationUpdate]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .revenueSystemConfiguration() - * .schedule() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddRevenueSystemConfigurationUpdate]. */ - class Builder internal constructor() { - - private var revenueSystemConfiguration: JsonField? = null - private var schedule: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): Schedule = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from( - addRevenueSystemConfigurationUpdate: AddRevenueSystemConfigurationUpdate - ) = apply { - revenueSystemConfiguration = - addRevenueSystemConfigurationUpdate.revenueSystemConfiguration - schedule = addRevenueSystemConfigurationUpdate.schedule - additionalProperties = - addRevenueSystemConfigurationUpdate.additionalProperties.toMutableMap() + creditTypeId() + doNotInvoice() + recurringSchedule().ifPresent { it.validate() } + scheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun revenueSystemConfiguration(revenueSystemConfiguration: RevenueSystemConfiguration) = - revenueSystemConfiguration(JsonField.of(revenueSystemConfiguration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.revenueSystemConfiguration] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.revenueSystemConfiguration] with a well-typed - * [RevenueSystemConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun revenueSystemConfiguration( - revenueSystemConfiguration: JsonField - ) = apply { this.revenueSystemConfiguration = revenueSystemConfiguration } - - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (doNotInvoice.asKnown().isPresent) 1 else 0) + + (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** - * Sets [Builder.schedule] to an arbitrary JSON value. - * - * You should usually call [Builder.schedule] with a well-typed [Schedule] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Enter the unit price and quantity for the charge or instead only send the amount. If + * amount is sent, the unit price is assumed to be the amount and quantity is inferred + * to be 1. */ - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + class RecurringSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amountDistribution: JsonField, + private val endingBefore: JsonField, + private val frequency: JsonField, + private val startingAt: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("amount_distribution") + @ExcludeMissing + amountDistribution: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + mutableMapOf(), + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amountDistribution(): AmountDistribution = + amountDistribution.getRequired("amount_distribution") + + /** + * RFC 3339 timestamp (exclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun frequency(): Frequency = frequency.getRequired("frequency") + + /** + * RFC 3339 timestamp (inclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Quantity for the charge. Will be multiplied by unit_price to determine the amount + * and must be specified with unit_price. If specified amount cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Unit price for the charge. Will be multiplied by quantity to determine the amount + * and must be specified with quantity. If specified amount cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [amountDistribution]. + * + * Unlike [amountDistribution], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_distribution") + @ExcludeMissing + fun _amountDistribution(): JsonField = amountDistribution - /** - * Returns an immutable instance of [AddRevenueSystemConfigurationUpdate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .revenueSystemConfiguration() - * .schedule() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddRevenueSystemConfigurationUpdate = - AddRevenueSystemConfigurationUpdate( - checkRequired("revenueSystemConfiguration", revenueSystemConfiguration), - checkRequired("schedule", schedule), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private var validated: Boolean = false + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddRevenueSystemConfigurationUpdate = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - revenueSystemConfiguration().validate() - schedule().validate() - validated = true - } + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (revenueSystemConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - class RevenueSystemConfiguration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val deliveryMethod: JsonField, - private val provider: JsonField, - private val revenueSystemConfigurationId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("delivery_method") - @ExcludeMissing - deliveryMethod: JsonField = JsonMissing.of(), - @JsonProperty("provider") - @ExcludeMissing - provider: JsonField = JsonMissing.of(), - @JsonProperty("revenue_system_configuration_id") + @JsonAnyGetter @ExcludeMissing - revenueSystemConfigurationId: JsonField = JsonMissing.of(), - ) : this(deliveryMethod, provider, revenueSystemConfigurationId, mutableMapOf()) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun deliveryMethod(): Optional = - deliveryMethod.getOptional("delivery_method") + fun toBuilder() = Builder().from(this) - /** - * The revenue system provider type. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun provider(): Optional = provider.getOptional("provider") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun revenueSystemConfigurationId(): Optional = - revenueSystemConfigurationId.getOptional("revenue_system_configuration_id") + /** + * Returns a mutable builder for constructing an instance of + * [RecurringSchedule]. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [deliveryMethod]. - * - * Unlike [deliveryMethod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("delivery_method") - @ExcludeMissing - fun _deliveryMethod(): JsonField = deliveryMethod + /** A builder for [RecurringSchedule]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [provider]. - * - * Unlike [provider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("provider") - @ExcludeMissing - fun _provider(): JsonField = provider + private var amountDistribution: JsonField? = null + private var endingBefore: JsonField? = null + private var frequency: JsonField? = null + private var startingAt: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [revenueSystemConfigurationId]. - * - * Unlike [revenueSystemConfigurationId], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("revenue_system_configuration_id") - @ExcludeMissing - fun _revenueSystemConfigurationId(): JsonField = revenueSystemConfigurationId + @JvmSynthetic + internal fun from(recurringSchedule: RecurringSchedule) = apply { + amountDistribution = recurringSchedule.amountDistribution + endingBefore = recurringSchedule.endingBefore + frequency = recurringSchedule.frequency + startingAt = recurringSchedule.startingAt + amount = recurringSchedule.amount + quantity = recurringSchedule.quantity + unitPrice = recurringSchedule.unitPrice + additionalProperties = recurringSchedule.additionalProperties.toMutableMap() + } + + fun amountDistribution(amountDistribution: AmountDistribution) = + amountDistribution(JsonField.of(amountDistribution)) + + /** + * Sets [Builder.amountDistribution] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDistribution] with a well-typed + * [AmountDistribution] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun amountDistribution(amountDistribution: JsonField) = + apply { + this.amountDistribution = amountDistribution + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** RFC 3339 timestamp (exclusive). */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - fun toBuilder() = Builder().from(this) + fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) - companion object { + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [Frequency] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } - /** - * Returns a mutable builder for constructing an instance of - * [RevenueSystemConfiguration]. - */ - @JvmStatic fun builder() = Builder() - } + /** RFC 3339 timestamp (inclusive). */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** A builder for [RevenueSystemConfiguration]. */ - class Builder internal constructor() { + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - private var deliveryMethod: JsonField = JsonMissing.of() - private var provider: JsonField = JsonMissing.of() - private var revenueSystemConfigurationId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) - @JvmSynthetic - internal fun from(revenueSystemConfiguration: RevenueSystemConfiguration) = apply { - deliveryMethod = revenueSystemConfiguration.deliveryMethod - provider = revenueSystemConfiguration.provider - revenueSystemConfigurationId = - revenueSystemConfiguration.revenueSystemConfigurationId - additionalProperties = - revenueSystemConfiguration.additionalProperties.toMutableMap() - } + /** + * 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 } - fun deliveryMethod(deliveryMethod: DeliveryMethod) = - deliveryMethod(JsonField.of(deliveryMethod)) + /** + * Quantity for the charge. Will be multiplied by unit_price to determine the + * amount and must be specified with unit_price. If specified amount cannot be + * provided. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - /** - * Sets [Builder.deliveryMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.deliveryMethod] with a well-typed - * [DeliveryMethod] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun deliveryMethod(deliveryMethod: JsonField) = apply { - this.deliveryMethod = deliveryMethod - } + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** The revenue system provider type. */ - fun provider(provider: Provider) = provider(JsonField.of(provider)) + /** + * Unit price for the charge. Will be multiplied by quantity to determine the + * amount and must be specified with quantity. If specified amount cannot be + * provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - /** - * Sets [Builder.provider] to an arbitrary JSON value. - * - * You should usually call [Builder.provider] with a well-typed [Provider] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun provider(provider: JsonField) = apply { this.provider = provider } + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - fun revenueSystemConfigurationId(revenueSystemConfigurationId: String) = - revenueSystemConfigurationId(JsonField.of(revenueSystemConfigurationId)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.revenueSystemConfigurationId] to an arbitrary JSON value. - * - * You should usually call [Builder.revenueSystemConfigurationId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun revenueSystemConfigurationId(revenueSystemConfigurationId: JsonField) = - apply { - this.revenueSystemConfigurationId = revenueSystemConfigurationId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an immutable instance of [RecurringSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringSchedule = + RecurringSchedule( + checkRequired("amountDistribution", amountDistribution), + checkRequired("endingBefore", endingBefore), + checkRequired("frequency", frequency), + checkRequired("startingAt", startingAt), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false /** - * Returns an immutable instance of [RevenueSystemConfiguration]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun build(): RevenueSystemConfiguration = - RevenueSystemConfiguration( - deliveryMethod, - provider, - revenueSystemConfigurationId, - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RevenueSystemConfiguration = apply { - if (validated) { - return@apply - } - - deliveryMethod().ifPresent { it.validate() } - provider().ifPresent { it.validate() } - revenueSystemConfigurationId() - validated = true - } + fun validate(): RecurringSchedule = apply { + if (validated) { + return@apply + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + amountDistribution().validate() + endingBefore() + frequency().validate() + startingAt() + amount() + quantity() + unitPrice() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (deliveryMethod.asKnown().getOrNull()?.validity() ?: 0) + - (provider.asKnown().getOrNull()?.validity() ?: 0) + - (if (revenueSystemConfigurationId.asKnown().isPresent) 1 else 0) - - class DeliveryMethod - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns this class instance's raw value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Used for best match union deserialization. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = + (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (frequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - companion object { + class AmountDistribution + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JvmField val DIRECT_TO_BILLING_PROVIDER = of("direct_to_billing_provider") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JvmField val AWS_SQS = of("aws_sqs") + companion object { - @JvmField val TACKLE = of("tackle") + @JvmField val DIVIDED = of("DIVIDED") - @JvmField val AWS_SNS = of("aws_sns") + @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") - @JvmStatic fun of(value: String) = DeliveryMethod(JsonField.of(value)) - } + @JvmField val EACH = of("EACH") - /** An enum containing [DeliveryMethod]'s known values. */ - enum class Known { - DIRECT_TO_BILLING_PROVIDER, - AWS_SQS, - TACKLE, - AWS_SNS, - } + @JvmStatic fun of(value: String) = AmountDistribution(JsonField.of(value)) + } + + /** An enum containing [AmountDistribution]'s known values. */ + enum class Known { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + } - /** - * An enum containing [DeliveryMethod]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DeliveryMethod] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIRECT_TO_BILLING_PROVIDER, - AWS_SQS, - TACKLE, - AWS_SNS, /** - * An enum member indicating that [DeliveryMethod] was instantiated with an - * unknown value. + * An enum containing [AmountDistribution]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AmountDistribution] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIRECT_TO_BILLING_PROVIDER -> Value.DIRECT_TO_BILLING_PROVIDER - AWS_SQS -> Value.AWS_SQS - TACKLE -> Value.TACKLE - AWS_SNS -> Value.AWS_SNS - else -> Value._UNKNOWN + enum class Value { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + /** + * An enum member indicating that [AmountDistribution] was instantiated with + * an unknown value. + */ + _UNKNOWN, } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DIRECT_TO_BILLING_PROVIDER -> Known.DIRECT_TO_BILLING_PROVIDER - AWS_SQS -> Known.AWS_SQS - TACKLE -> Known.TACKLE - AWS_SNS -> Known.AWS_SNS - else -> - throw MetronomeInvalidDataException("Unknown DeliveryMethod: $value") - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDED -> Value.DIVIDED + DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED + EACH -> Value.EACH + else -> Value._UNKNOWN + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DIVIDED -> Known.DIVIDED + DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED + EACH -> Known.EACH + else -> + throw MetronomeInvalidDataException( + "Unknown AmountDistribution: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AmountDistribution = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): DeliveryMethod = apply { - if (validated) { - return@apply + return other is AmountDistribution && value == other.value } - known() - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + class Frequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is DeliveryMethod && value == other.value - } + @JvmField val MONTHLY = of("MONTHLY") - override fun hashCode() = value.hashCode() + @JvmField val QUARTERLY = of("QUARTERLY") - override fun toString() = value.toString() - } + @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") - /** The revenue system provider type. */ - class Provider @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField val ANNUAL = of("ANNUAL") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmField val WEEKLY = of("WEEKLY") - companion object { + @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) + } - @JvmField val NETSUITE = of("netsuite") + /** An enum containing [Frequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + } - @JvmStatic fun of(value: String) = Provider(JsonField.of(value)) - } + /** + * An enum containing [Frequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Frequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [Frequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** An enum containing [Provider]'s known values. */ - enum class Known { - NETSUITE - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } - /** - * An enum containing [Provider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Provider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NETSUITE, /** - * An enum member indicating that [Provider] was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. */ - _UNKNOWN, - } + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> throw MetronomeInvalidDataException("Unknown Frequency: $value") + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NETSUITE -> Value.NETSUITE - else -> Value._UNKNOWN - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NETSUITE -> Known.NETSUITE - else -> throw MetronomeInvalidDataException("Unknown Provider: $value") - } + private var validated: Boolean = false - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Frequency = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Provider = apply { - if (validated) { - return@apply + return other is Frequency && value == other.value } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Provider && value == other.value + return other is RecurringSchedule && + amountDistribution == other.amountDistribution && + endingBefore == other.endingBefore && + frequency == other.frequency && + startingAt == other.startingAt && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + private val hashCode: Int by lazy { + Objects.hash( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + additionalProperties, + ) } - return other is RevenueSystemConfiguration && - deliveryMethod == other.deliveryMethod && - provider == other.provider && - revenueSystemConfigurationId == other.revenueSystemConfigurationId && - additionalProperties == other.additionalProperties - } + override fun hashCode(): Int = hashCode - private val hashCode: Int by lazy { - Objects.hash( - deliveryMethod, - provider, - revenueSystemConfigurationId, - additionalProperties, - ) + override fun toString() = + "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - override fun hashCode(): Int = hashCode - - override fun toString() = - "RevenueSystemConfiguration{deliveryMethod=$deliveryMethod, provider=$provider, revenueSystemConfigurationId=$revenueSystemConfigurationId, additionalProperties=$additionalProperties}" - } - - class Schedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val effectiveAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator + class ScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @JsonProperty("effective_at") - @ExcludeMissing - effectiveAt: JsonField = JsonMissing.of() - ) : this(effectiveAt, mutableMapOf()) - - /** - * When the revenue system configuration update will take effect. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun effectiveAt(): EffectiveAt = effectiveAt.getRequired("effective_at") - - /** - * Returns the raw JSON value of [effectiveAt]. - * - * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("effective_at") - @ExcludeMissing - fun _effectiveAt(): JsonField = effectiveAt - - @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) + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) /** - * Returns a mutable builder for constructing an instance of [Schedule]. + * timestamp of the scheduled event * - * The following fields are required: - * ```java - * .effectiveAt() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Schedule]. */ - class Builder internal constructor() { - - private var effectiveAt: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - effectiveAt = schedule.effectiveAt - additionalProperties = schedule.additionalProperties.toMutableMap() - } - - /** When the revenue system configuration update will take effect. */ - fun effectiveAt(effectiveAt: EffectiveAt) = effectiveAt(JsonField.of(effectiveAt)) + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") /** - * Sets [Builder.effectiveAt] to an arbitrary JSON value. + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. * - * You should usually call [Builder.effectiveAt] with a well-typed [EffectiveAt] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun effectiveAt(effectiveAt: JsonField) = apply { - this.effectiveAt = effectiveAt - } + fun amount(): Optional = amount.getOptional("amount") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Quantity for the charge. Will be multiplied by unit_price to determine the amount + * and must be specified with unit_price. If specified amount cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Unit price for the charge. Will be multiplied by quantity to determine the amount + * and must be specified with quantity. If specified amount cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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 - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * 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 - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Returns an immutable instance of [Schedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .effectiveAt() - * ``` + * Returns the raw JSON value of [unitPrice]. * - * @throws IllegalStateException if any required field is unset. + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun build(): Schedule = - Schedule( - checkRequired("effectiveAt", effectiveAt), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Schedule = apply { - if (validated) { - return@apply + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - effectiveAt().validate() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScheduleItem]. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (effectiveAt.asKnown().getOrNull()?.validity() ?: 0) + /** A builder for [ScheduleItem]. */ + class Builder internal constructor() { - /** When the revenue system configuration update will take effect. */ - class EffectiveAt - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmSynthetic + internal fun from(scheduleItem: ScheduleItem) = apply { + timestamp = scheduleItem.timestamp + amount = scheduleItem.amount + quantity = scheduleItem.quantity + unitPrice = scheduleItem.unitPrice + additionalProperties = scheduleItem.additionalProperties.toMutableMap() + } - companion object { + /** timestamp of the scheduled event */ + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) - @JvmField val START_OF_CURRENT_PERIOD = of("START_OF_CURRENT_PERIOD") + /** + * 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 + } - @JvmStatic fun of(value: String) = EffectiveAt(JsonField.of(value)) - } + /** + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** An enum containing [EffectiveAt]'s known values. */ - enum class Known { - START_OF_CURRENT_PERIOD - } + /** + * 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 } - /** - * An enum containing [EffectiveAt]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EffectiveAt] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - START_OF_CURRENT_PERIOD, /** - * An enum member indicating that [EffectiveAt] was instantiated with an unknown - * value. + * Quantity for the charge. Will be multiplied by unit_price to determine the + * amount and must be specified with unit_price. If specified amount cannot be + * provided. */ - _UNKNOWN, - } + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - START_OF_CURRENT_PERIOD -> Value.START_OF_CURRENT_PERIOD - else -> Value._UNKNOWN + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** + * Unit price for the charge. Will be multiplied by quantity to determine the + * amount and must be specified with quantity. If specified amount cannot be + * provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - START_OF_CURRENT_PERIOD -> Known.START_OF_CURRENT_PERIOD - else -> throw MetronomeInvalidDataException("Unknown EffectiveAt: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScheduleItem = + ScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -24980,12 +28413,15 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): EffectiveAt = apply { + fun validate(): ScheduleItem = apply { if (validated) { return@apply } - known() + timestamp() + amount() + quantity() + unitPrice() validated = true } @@ -25003,2327 +28439,2276 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EffectiveAt && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Schedule && - effectiveAt == other.effectiveAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(effectiveAt, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Schedule{effectiveAt=$effectiveAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddRevenueSystemConfigurationUpdate && - revenueSystemConfiguration == other.revenueSystemConfiguration && - schedule == other.schedule && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(revenueSystemConfiguration, schedule, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddRevenueSystemConfigurationUpdate{revenueSystemConfiguration=$revenueSystemConfiguration, schedule=$schedule, additionalProperties=$additionalProperties}" - } - - class AddScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val productId: JsonField, - private val schedule: JsonField, - private val customFields: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - ) : this(productId, schedule, customFields, name, netsuiteSalesOrderId, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun productId(): String = productId.getRequired("product_id") - - /** - * Must provide either schedule_items or recurring_schedule. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun schedule(): Schedule = schedule.getRequired("schedule") - - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") - - /** - * displayed on invoices - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * This field's availability is dependent on your client's configuration. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId - - /** - * Returns the raw JSON value of [schedule]. - * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("schedule") @ExcludeMissing fun _schedule(): JsonField = schedule - - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - - @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 [AddScheduledCharge]. - * - * The following fields are required: - * ```java - * .productId() - * .schedule() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddScheduledCharge]. */ - class Builder internal constructor() { - - private var productId: JsonField? = null - private var schedule: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addScheduledCharge: AddScheduledCharge) = apply { - productId = addScheduledCharge.productId - schedule = addScheduledCharge.schedule - customFields = addScheduledCharge.customFields - name = addScheduledCharge.name - netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId - additionalProperties = addScheduledCharge.additionalProperties.toMutableMap() - } - - fun productId(productId: String) = productId(JsonField.of(productId)) - - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } - - /** Must provide either schedule_items or recurring_schedule. */ - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) - - /** - * Sets [Builder.schedule] to an arbitrary JSON value. - * - * You should usually call [Builder.schedule] with a well-typed [Schedule] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } - - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** displayed on invoices */ - fun name(name: String) = name(JsonField.of(name)) + return other is ScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + private val hashCode: Int by lazy { + Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + } - /** This field's availability is dependent on your client's configuration. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId + override fun toString() = + "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + return other is Schedule && + creditTypeId == other.creditTypeId && + doNotInvoice == other.doNotInvoice && + recurringSchedule == other.recurringSchedule && + scheduleItems == other.scheduleItems && + additionalProperties == other.additionalProperties } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + additionalProperties, + ) } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [AddScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .productId() - * .schedule() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddScheduledCharge = - AddScheduledCharge( - checkRequired("productId", productId), - checkRequired("schedule", schedule), - customFields, - name, - netsuiteSalesOrderId, - additionalProperties.toMutableMap(), - ) + override fun toString() = + "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddScheduledCharge = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - productId() - schedule().validate() - customFields().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomFields]. */ + @JvmStatic fun builder() = Builder() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (productId.asKnown().isPresent) 1 else 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + /** A builder for [CustomFields]. */ + class Builder internal constructor() { - /** Must provide either schedule_items or recurring_schedule. */ - class Schedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val doNotInvoice: JsonField, - private val recurringSchedule: JsonField, - private val scheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + private var additionalProperties: MutableMap = mutableMapOf() - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("do_not_invoice") - @ExcludeMissing - doNotInvoice: JsonField = JsonMissing.of(), - @JsonProperty("recurring_schedule") - @ExcludeMissing - recurringSchedule: JsonField = JsonMissing.of(), - @JsonProperty("schedule_items") - @ExcludeMissing - scheduleItems: JsonField> = JsonMissing.of(), - ) : this(creditTypeId, doNotInvoice, recurringSchedule, scheduleItems, mutableMapOf()) + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } - /** - * Defaults to USD (cents) if not passed. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun creditTypeId(): Optional = creditTypeId.getOptional("credit_type_id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * This field is only applicable to commit invoice schedules. If true, this schedule - * will not generate an invoice. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun doNotInvoice(): Optional = doNotInvoice.getOptional("do_not_invoice") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Enter the unit price and quantity for the charge or instead only send the amount. If - * amount is sent, the unit price is assumed to be the amount and quantity is inferred - * to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun recurringSchedule(): Optional = - recurringSchedule.getOptional("recurring_schedule") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Either provide amount or provide both unit_price and quantity. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun scheduleItems(): Optional> = - scheduleItems.getOptional("schedule_items") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [doNotInvoice]. - * - * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("do_not_invoice") - @ExcludeMissing - fun _doNotInvoice(): JsonField = doNotInvoice + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [recurringSchedule]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [recurringSchedule], this method doesn't throw if the JSON field has an - * unexpected type. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JsonProperty("recurring_schedule") - @ExcludeMissing - fun _recurringSchedule(): JsonField = recurringSchedule + fun validate(): CustomFields = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [scheduleItems]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [scheduleItems], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("schedule_items") - @ExcludeMissing - fun _scheduleItems(): JsonField> = scheduleItems + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFields && additionalProperties == other.additionalProperties } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + } - /** Returns a mutable builder for constructing an instance of [Schedule]. */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Schedule]. */ - class Builder internal constructor() { + return other is AddScheduledCharge && + productId == other.productId && + schedule == other.schedule && + customFields == other.customFields && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + additionalProperties == other.additionalProperties + } - private var creditTypeId: JsonField = JsonMissing.of() - private var doNotInvoice: JsonField = JsonMissing.of() - private var recurringSchedule: JsonField = JsonMissing.of() - private var scheduleItems: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash( + productId, + schedule, + customFields, + name, + netsuiteSalesOrderId, + additionalProperties, + ) + } - @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - creditTypeId = schedule.creditTypeId - doNotInvoice = schedule.doNotInvoice - recurringSchedule = schedule.recurringSchedule - scheduleItems = schedule.scheduleItems.map { it.toMutableList() } - additionalProperties = schedule.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - /** Defaults to USD (cents) if not passed. */ - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) + override fun toString() = + "AddScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + class AddSpendTracker + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val alias: JsonField, + private val applicableSpendSpecifiers: JsonField>, + private val creditTypeId: JsonField, + private val resetFrequency: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * This field is only applicable to commit invoice schedules. If true, this schedule - * will not generate an invoice. - */ - fun doNotInvoice(doNotInvoice: Boolean) = doNotInvoice(JsonField.of(doNotInvoice)) + @JsonCreator + private constructor( + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + applicableSpendSpecifiers: JsonField> = JsonMissing.of(), + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("reset_frequency") + @ExcludeMissing + resetFrequency: JsonField = JsonMissing.of(), + ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) - /** - * Sets [Builder.doNotInvoice] to an arbitrary JSON value. - * - * You should usually call [Builder.doNotInvoice] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun doNotInvoice(doNotInvoice: JsonField) = apply { - this.doNotInvoice = doNotInvoice - } + /** + * Human-readable identifier, unique per contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun alias(): String = alias.getRequired("alias") - /** - * Enter the unit price and quantity for the charge or instead only send the amount. - * If amount is sent, the unit price is assumed to be the amount and quantity is - * inferred to be 1. - */ - fun recurringSchedule(recurringSchedule: RecurringSchedule) = - recurringSchedule(JsonField.of(recurringSchedule)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun applicableSpendSpecifiers(): List = + applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") - /** - * Sets [Builder.recurringSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.recurringSchedule] with a well-typed - * [RecurringSchedule] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun recurringSchedule(recurringSchedule: JsonField) = apply { - this.recurringSchedule = recurringSchedule - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - /** Either provide amount or provide both unit_price and quantity. */ - fun scheduleItems(scheduleItems: List) = - scheduleItems(JsonField.of(scheduleItems)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") - /** - * Sets [Builder.scheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.scheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun scheduleItems(scheduleItems: JsonField>) = apply { - this.scheduleItems = scheduleItems.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - /** - * Adds a single [ScheduleItem] to [scheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addScheduleItem(scheduleItem: ScheduleItem) = apply { - scheduleItems = - (scheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("scheduleItems", it).add(scheduleItem) - } - } + /** + * Returns the raw JSON value of [applicableSpendSpecifiers]. + * + * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_spend_specifiers") + @ExcludeMissing + fun _applicableSpendSpecifiers(): JsonField> = + applicableSpendSpecifiers + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [resetFrequency]. + * + * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reset_frequency") + @ExcludeMissing + fun _resetFrequency(): JsonField = resetFrequency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of [AddSpendTracker]. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [AddSpendTracker]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [Schedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Schedule = - Schedule( - creditTypeId, - doNotInvoice, - recurringSchedule, - (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + private var alias: JsonField? = null + private var applicableSpendSpecifiers: + JsonField>? = + null + private var creditTypeId: JsonField? = null + private var resetFrequency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addSpendTracker: AddSpendTracker) = apply { + alias = addSpendTracker.alias + applicableSpendSpecifiers = + addSpendTracker.applicableSpendSpecifiers.map { it.toMutableList() } + creditTypeId = addSpendTracker.creditTypeId + resetFrequency = addSpendTracker.resetFrequency + additionalProperties = addSpendTracker.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** Human-readable identifier, unique per contract. */ + fun alias(alias: String) = alias(JsonField.of(alias)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.alias] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): Schedule = apply { - if (validated) { - return@apply - } - - creditTypeId() - doNotInvoice() - recurringSchedule().ifPresent { it.validate() } - scheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + fun alias(alias: JsonField) = apply { this.alias = alias } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: List + ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (doNotInvoice.asKnown().isPresent) 1 else 0) + - (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + fun applicableSpendSpecifiers( + applicableSpendSpecifiers: JsonField> + ) = apply { + this.applicableSpendSpecifiers = + applicableSpendSpecifiers.map { it.toMutableList() } + } /** - * Enter the unit price and quantity for the charge or instead only send the amount. If - * amount is sent, the unit price is assumed to be the amount and quantity is inferred - * to be 1. + * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - class RecurringSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amountDistribution: JsonField, - private val endingBefore: JsonField, - private val frequency: JsonField, - private val startingAt: JsonField, - private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount_distribution") - @ExcludeMissing - amountDistribution: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - frequency: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - mutableMapOf(), - ) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun amountDistribution(): AmountDistribution = - amountDistribution.getRequired("amount_distribution") + fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = + apply { + applicableSpendSpecifiers = + (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableSpendSpecifiers", it) + .add(applicableSpendSpecifier) + } + } - /** - * RFC 3339 timestamp (exclusive). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun frequency(): Frequency = frequency.getRequired("frequency") + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } - /** - * RFC 3339 timestamp (inclusive). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun resetFrequency(resetFrequency: ResetFrequency) = + resetFrequency(JsonField.of(resetFrequency)) - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + /** + * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun resetFrequency(resetFrequency: JsonField) = apply { + this.resetFrequency = resetFrequency + } - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the amount - * and must be specified with unit_price. If specified amount cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Unit price for the charge. Will be multiplied by quantity to determine the amount - * and must be specified with quantity. If specified amount cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [amountDistribution]. - * - * Unlike [amountDistribution], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount_distribution") - @ExcludeMissing - fun _amountDistribution(): JsonField = amountDistribution + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [frequency]. - * - * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Returns an immutable instance of [AddSpendTracker]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .alias() + * .applicableSpendSpecifiers() + * .creditTypeId() + * .resetFrequency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddSpendTracker = + AddSpendTracker( + checkRequired("alias", alias), + checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { + it.toImmutable() + }, + checkRequired("creditTypeId", creditTypeId), + checkRequired("resetFrequency", resetFrequency), + additionalProperties.toMutableMap(), + ) + } - /** - * 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 + private var validated: Boolean = false - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddSpendTracker = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + alias() + applicableSpendSpecifiers().forEach { it.validate() } + creditTypeId() + resetFrequency().validate() + validated = true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonAnyGetter + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (alias.asKnown().isPresent) 1 else 0) + + (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + + class ApplicableSpendSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sources: JsonField>, + private val spendType: JsonField, + private val discounted: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sources") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + sources: JsonField> = JsonMissing.of(), + @JsonProperty("spend_type") + @ExcludeMissing + spendType: JsonField = JsonMissing.of(), + @JsonProperty("discounted") + @ExcludeMissing + discounted: JsonField = JsonMissing.of(), + ) : this(sources, spendType, discounted, mutableMapOf()) - fun toBuilder() = Builder().from(this) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun sources(): List = sources.getRequired("sources") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun spendType(): SpendType = spendType.getRequired("spend_type") - /** - * Returns a mutable builder for constructing an instance of - * [RecurringSchedule]. - * - * The following fields are required: - * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Filter by whether the spend was discounted. Defaults to ANY if omitted. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun discounted(): Optional = discounted.getOptional("discounted") - /** A builder for [RecurringSchedule]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [sources]. + * + * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sources") + @ExcludeMissing + fun _sources(): JsonField> = sources - private var amountDistribution: JsonField? = null - private var endingBefore: JsonField? = null - private var frequency: JsonField? = null - private var startingAt: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [spendType]. + * + * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spend_type") + @ExcludeMissing + fun _spendType(): JsonField = spendType - @JvmSynthetic - internal fun from(recurringSchedule: RecurringSchedule) = apply { - amountDistribution = recurringSchedule.amountDistribution - endingBefore = recurringSchedule.endingBefore - frequency = recurringSchedule.frequency - startingAt = recurringSchedule.startingAt - amount = recurringSchedule.amount - quantity = recurringSchedule.quantity - unitPrice = recurringSchedule.unitPrice - additionalProperties = recurringSchedule.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [discounted]. + * + * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discounted") + @ExcludeMissing + fun _discounted(): JsonField = discounted - fun amountDistribution(amountDistribution: AmountDistribution) = - amountDistribution(JsonField.of(amountDistribution)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.amountDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.amountDistribution] with a well-typed - * [AmountDistribution] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun amountDistribution(amountDistribution: JsonField) = - apply { - this.amountDistribution = amountDistribution - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** RFC 3339 timestamp (exclusive). */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + companion object { - fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) + /** + * Returns a mutable builder for constructing an instance of + * [ApplicableSpendSpecifier]. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.frequency] to an arbitrary JSON value. - * - * You should usually call [Builder.frequency] with a well-typed [Frequency] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } + /** A builder for [ApplicableSpendSpecifier]. */ + class Builder internal constructor() { - /** RFC 3339 timestamp (inclusive). */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + private var sources: JsonField>? = null + private var spendType: JsonField? = null + private var discounted: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + @JvmSynthetic + internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { + sources = applicableSpendSpecifier.sources.map { it.toMutableList() } + spendType = applicableSpendSpecifier.spendType + discounted = applicableSpendSpecifier.discounted + additionalProperties = + applicableSpendSpecifier.additionalProperties.toMutableMap() + } - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) + fun sources(sources: List) = sources(JsonField.of(sources)) - /** - * 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 } + /** + * Sets [Builder.sources] to an arbitrary JSON value. + * + * You should usually call [Builder.sources] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sources(sources: JsonField>) = apply { + this.sources = sources.map { it.toMutableList() } + } - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the - * amount and must be specified with unit_price. If specified amount cannot be - * provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** + * Adds a single [Source] to [sources]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSource(source: Source) = apply { + sources = + (sources ?: JsonField.of(mutableListOf())).also { + checkKnown("sources", it).add(source) + } + } - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) - /** - * Unit price for the charge. Will be multiplied by quantity to determine the - * amount and must be specified with quantity. If specified amount cannot be - * provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** + * Sets [Builder.spendType] to an arbitrary JSON value. + * + * You should usually call [Builder.spendType] with a well-typed [SpendType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun spendType(spendType: JsonField) = apply { + this.spendType = spendType + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.discounted] to an arbitrary JSON value. + * + * You should usually call [Builder.discounted] with a well-typed [Discounted] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun discounted(discounted: JsonField) = apply { + this.discounted = discounted + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns an immutable instance of [RecurringSchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RecurringSchedule = - RecurringSchedule( - checkRequired("amountDistribution", amountDistribution), - checkRequired("endingBefore", endingBefore), - checkRequired("frequency", frequency), - checkRequired("startingAt", startingAt), - amount, - quantity, - unitPrice, - additionalProperties.toMutableMap(), - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - private var validated: Boolean = false + /** + * Returns an immutable instance of [ApplicableSpendSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sources() + * .spendType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApplicableSpendSpecifier = + ApplicableSpendSpecifier( + checkRequired("sources", sources).map { it.toImmutable() }, + checkRequired("spendType", spendType), + discounted, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ApplicableSpendSpecifier = apply { + if (validated) { + return@apply + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): RecurringSchedule = apply { - if (validated) { - return@apply - } + sources().forEach { it.validate() } + spendType().validate() + discounted().ifPresent { it.validate() } + validated = true + } - amountDistribution().validate() - endingBefore() - frequency().validate() - startingAt() - amount() - quantity() - unitPrice() - validated = true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (spendType.asKnown().getOrNull()?.validity() ?: 0) + + (discounted.asKnown().getOrNull()?.validity() ?: 0) + + class Source @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns this class instance's raw value. * - * Used for best match union deserialization. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JvmSynthetic - internal fun validity(): Int = - (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (frequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - class AmountDistribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") - companion object { + @JvmField val MANUAL = of("MANUAL") - @JvmField val DIVIDED = of("DIVIDED") + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } - @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") + /** An enum containing [Source]'s known values. */ + enum class Known { + THRESHOLD_RECHARGE, + MANUAL, + } - @JvmField val EACH = of("EACH") + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_RECHARGE, + MANUAL, + /** + * An enum member indicating that [Source] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - @JvmStatic fun of(value: String) = AmountDistribution(JsonField.of(value)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE + MANUAL -> Value.MANUAL + else -> Value._UNKNOWN } - /** An enum containing [AmountDistribution]'s known values. */ - enum class Known { - DIVIDED, - DIVIDED_ROUNDED, - EACH, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE + MANUAL -> Known.MANUAL + else -> throw MetronomeInvalidDataException("Unknown Source: $value") } - /** - * An enum containing [AmountDistribution]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AmountDistribution] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDED, - DIVIDED_ROUNDED, - EACH, - /** - * An enum member indicating that [AmountDistribution] was instantiated with - * an unknown value. - */ - _UNKNOWN, + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDED -> Value.DIVIDED - DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED - EACH -> Value.EACH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - DIVIDED -> Known.DIVIDED - DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED - EACH -> Known.EACH - else -> - throw MetronomeInvalidDataException( - "Unknown AmountDistribution: $value" - ) - } + private var validated: Boolean = false - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Source = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + known() + validated = true + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AmountDistribution = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - known() - validated = true + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is Source && value == other.value + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun toString() = value.toString() + } - return other is AmountDistribution && value == other.value - } + class SpendType @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun hashCode() = value.hashCode() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun toString() = value.toString() + companion object { + + @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + + @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) } - class Frequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [SpendType]'s known values. */ + enum class Known { + COMMIT_PURCHASE + } + /** + * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SpendType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_PURCHASE, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [SpendType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + _UNKNOWN, + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_PURCHASE -> Value.COMMIT_PURCHASE + else -> Value._UNKNOWN + } - @JvmField val MONTHLY = of("MONTHLY") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_PURCHASE -> Known.COMMIT_PURCHASE + else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") + } - @JvmField val QUARTERLY = of("QUARTERLY") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") + private var validated: Boolean = false - @JvmField val ANNUAL = of("ANNUAL") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SpendType = apply { + if (validated) { + return@apply + } - @JvmField val WEEKLY = of("WEEKLY") + known() + validated = true + } - @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - /** An enum containing [Frequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * An enum containing [Frequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Frequency] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [Frequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + return other is SpendType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ + class Discounted + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> throw MetronomeInvalidDataException("Unknown Frequency: $value") - } + companion object { - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JvmField val ANY = of("ANY") - private var validated: Boolean = false + @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Frequency = apply { - if (validated) { - return@apply - } + @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") - known() - validated = true - } + @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** An enum containing [Discounted]'s known values. */ + enum class Known { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, + } + /** + * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Discounted] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANY, + DISCOUNTED_ONLY, + UNDISCOUNTED_ONLY, /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * An enum member indicating that [Discounted] was instantiated with an unknown + * value. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + _UNKNOWN, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANY -> Value.ANY + DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY + else -> Value._UNKNOWN + } - return other is Frequency && value == other.value + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANY -> Known.ANY + DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY + UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY + else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") } - override fun hashCode() = value.hashCode() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - override fun toString() = value.toString() + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Discounted = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is RecurringSchedule && - amountDistribution == other.amountDistribution && - endingBefore == other.endingBefore && - frequency == other.frequency && - startingAt == other.startingAt && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties + return other is Discounted && value == other.value } - private val hashCode: Int by lazy { - Objects.hash( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - additionalProperties, - ) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode(): Int = hashCode + return other is ApplicableSpendSpecifier && + sources == other.sources && + spendType == other.spendType && + discounted == other.discounted && + additionalProperties == other.additionalProperties + } - override fun toString() = - "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + private val hashCode: Int by lazy { + Objects.hash(sources, spendType, discounted, additionalProperties) } - class ScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val timestamp: JsonField, - private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun hashCode(): Int = hashCode - @JsonCreator - private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + override fun toString() = + "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" + } + + class ResetFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * timestamp of the scheduled event - * - * @throws MetronomeInvalidDataException if 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") + companion object { - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the amount - * and must be specified with unit_price. If specified amount cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) + } - /** - * Unit price for the charge. Will be multiplied by quantity to determine the amount - * and must be specified with quantity. If specified amount cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + /** An enum containing [ResetFrequency]'s known values. */ + enum class Known { + BILLING_PERIOD + } + /** + * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILLING_PERIOD, /** - * Returns the raw JSON value of [timestamp]. - * - * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected - * type. + * An enum member indicating that [ResetFrequency] was instantiated with an unknown + * value. */ - @JsonProperty("timestamp") - @ExcludeMissing - fun _timestamp(): JsonField = timestamp + _UNKNOWN, + } - /** - * 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 an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILLING_PERIOD -> Value.BILLING_PERIOD + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BILLING_PERIOD -> Known.BILLING_PERIOD + else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") + } - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ResetFrequency = apply { + if (validated) { + return@apply } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + known() + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns a mutable builder for constructing an instance of [ScheduleItem]. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [ScheduleItem]. */ - class Builder internal constructor() { + return other is ResetFrequency && value == other.value + } - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun hashCode() = value.hashCode() - @JvmSynthetic - internal fun from(scheduleItem: ScheduleItem) = apply { - timestamp = scheduleItem.timestamp - amount = scheduleItem.amount - quantity = scheduleItem.quantity - unitPrice = scheduleItem.unitPrice - additionalProperties = scheduleItem.additionalProperties.toMutableMap() - } + override fun toString() = value.toString() + } - /** timestamp of the scheduled event */ - fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 - } + return other is AddSpendTracker && + alias == other.alias && + applicableSpendSpecifiers == other.applicableSpendSpecifiers && + creditTypeId == other.creditTypeId && + resetFrequency == other.resetFrequency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + alias, + applicableSpendSpecifiers, + creditTypeId, + resetFrequency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddSpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" + } + + class AddSubscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val subscriptionRate: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val initialQuantity: JsonField, + private val name: JsonField, + private val quantityManagementMode: JsonField, + private val seatConfig: JsonField, + private val startingAt: JsonField, + private val temporaryId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) + @JsonCreator + private constructor( + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("initial_quantity") + @ExcludeMissing + initialQuantity: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("temporary_id") + @ExcludeMissing + temporaryId: JsonField = JsonMissing.of(), + ) : this( + collectionSchedule, + proration, + subscriptionRate, + billingCycleConfig, + customFields, + description, + endingBefore, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAt, + temporaryId, + mutableMapOf(), + ) - /** - * 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 } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the - * amount and must be specified with unit_price. If specified amount cannot be - * provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun proration(): Proration = proration.getRequired("proration") - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") - /** - * Unit price for the charge. Will be multiplied by quantity to determine the - * amount and must be specified with quantity. If specified amount cannot be - * provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Exclusive end time for the subscription. If not provided, subscription inherits contract + * end date. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantityManagementMode(): Optional = + quantityManagementMode.getOptional("quantity_management_mode") - /** - * Returns an immutable instance of [ScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScheduleItem = - ScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, - additionalProperties.toMutableMap(), - ) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - private var validated: Boolean = false + /** + * Inclusive start time for the subscription. If not provided, defaults to contract start + * date + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startingAt(): Optional = startingAt.getOptional("starting_at") - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ScheduleItem = apply { - if (validated) { - return@apply - } + /** + * A temporary ID used to reference the subscription in recurring commit/credit subscription + * configs created within the same payload. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - timestamp() - amount() - quantity() - unitPrice() - validated = true - } + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - return other is ScheduleItem && - timestamp == other.timestamp && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - private val hashCode: Int by lazy { - Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [initialQuantity]. + * + * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("initial_quantity") + @ExcludeMissing + fun _initialQuantity(): JsonField = initialQuantity - override fun toString() = - "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = quantityManagementMode - return other is Schedule && - creditTypeId == other.creditTypeId && - doNotInvoice == other.doNotInvoice && - recurringSchedule == other.recurringSchedule && - scheduleItems == other.scheduleItems && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - private val hashCode: Int by lazy { - Objects.hash( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - additionalProperties, - ) - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [temporaryId]. + * + * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("temporary_id") + @ExcludeMissing + fun _temporaryId(): JsonField = temporaryId - override fun toString() = - "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun toBuilder() = Builder().from(this) + fun toBuilder() = Builder().from(this) - companion object { + companion object { - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns a mutable builder for constructing an instance of [AddSubscription]. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** A builder for [AddSubscription]. */ + class Builder internal constructor() { - private var additionalProperties: MutableMap = mutableMapOf() + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var subscriptionRate: JsonField? = null + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var initialQuantity: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var quantityManagementMode: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var temporaryId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + @JvmSynthetic + internal fun from(addSubscription: AddSubscription) = apply { + collectionSchedule = addSubscription.collectionSchedule + proration = addSubscription.proration + subscriptionRate = addSubscription.subscriptionRate + billingCycleConfig = addSubscription.billingCycleConfig + customFields = addSubscription.customFields + description = addSubscription.description + endingBefore = addSubscription.endingBefore + initialQuantity = addSubscription.initialQuantity + name = addSubscription.name + quantityManagementMode = addSubscription.quantityManagementMode + seatConfig = addSubscription.seatConfig + startingAt = addSubscription.startingAt + temporaryId = addSubscription.temporaryId + additionalProperties = addSubscription.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun proration(proration: Proration) = proration(JsonField.of(proration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun proration(proration: JsonField) = apply { this.proration = proration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate } - private var validated: Boolean = false + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) /** - * Validates that the types of all values in this object match their expected types - * recursively. + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig + } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + + /** + * Sets [Builder.customFields] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.customFields] with a well-typed [CustomFields] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } - validated = true + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Exclusive end time for the subscription. If not provided, subscription inherits + * contract end date. + */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The initial quantity for the subscription. It must be non-negative value. Required if + * quantity_management_mode is QUANTITY_ONLY. + */ + fun initialQuantity(initialQuantity: Double) = + initialQuantity(JsonField.of(initialQuantity)) - return other is CustomFields && additionalProperties == other.additionalProperties + /** + * Sets [Builder.initialQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.initialQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun initialQuantity(initialQuantity: JsonField) = apply { + this.initialQuantity = initialQuantity } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun name(name: String) = name(JsonField.of(name)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" - } + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per + * seat. `seat_config` must be provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode(quantityManagementMode: JsonField) = + apply { + this.quantityManagementMode = quantityManagementMode + } - return other is AddScheduledCharge && - productId == other.productId && - schedule == other.schedule && - customFields == other.customFields && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - additionalProperties == other.additionalProperties - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - private val hashCode: Int by lazy { - Objects.hash( - productId, - schedule, - customFields, - name, - netsuiteSalesOrderId, - additionalProperties, - ) - } + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } - override fun hashCode(): Int = hashCode + /** + * Inclusive start time for the subscription. If not provided, defaults to contract + * start date + */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) - override fun toString() = - "AddScheduledCharge{productId=$productId, schedule=$schedule, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - class AddSpendTracker - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val alias: JsonField, - private val applicableSpendSpecifiers: JsonField>, - private val creditTypeId: JsonField, - private val resetFrequency: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * A temporary ID used to reference the subscription in recurring commit/credit + * subscription configs created within the same payload. + */ + fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) - @JsonCreator - private constructor( - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - applicableSpendSpecifiers: JsonField> = JsonMissing.of(), - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("reset_frequency") - @ExcludeMissing - resetFrequency: JsonField = JsonMissing.of(), - ) : this(alias, applicableSpendSpecifiers, creditTypeId, resetFrequency, mutableMapOf()) + /** + * Sets [Builder.temporaryId] to an arbitrary JSON value. + * + * You should usually call [Builder.temporaryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun temporaryId(temporaryId: JsonField) = apply { + this.temporaryId = temporaryId + } - /** - * Human-readable identifier, unique per contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun alias(): String = alias.getRequired("alias") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun applicableSpendSpecifiers(): List = - applicableSpendSpecifiers.getRequired("applicable_spend_specifiers") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun resetFrequency(): ResetFrequency = resetFrequency.getRequired("reset_frequency") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [applicableSpendSpecifiers]. - * - * Unlike [applicableSpendSpecifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_spend_specifiers") - @ExcludeMissing - fun _applicableSpendSpecifiers(): JsonField> = - applicableSpendSpecifiers + /** + * Returns an immutable instance of [AddSubscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collectionSchedule() + * .proration() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddSubscription = + AddSubscription( + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("subscriptionRate", subscriptionRate), + billingCycleConfig, + customFields, + description, + endingBefore, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAt, + temporaryId, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + private var validated: Boolean = false /** - * Returns the raw JSON value of [resetFrequency]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [resetFrequency], this method doesn't throw if the JSON field has an unexpected - * type. + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. */ - @JsonProperty("reset_frequency") - @ExcludeMissing - fun _resetFrequency(): JsonField = resetFrequency + fun validate(): AddSubscription = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + collectionSchedule().validate() + proration().validate() + subscriptionRate().validate() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + endingBefore() + initialQuantity() + name() + quantityManagementMode().ifPresent { it.validate() } + seatConfig().ifPresent { it.validate() } + startingAt() + temporaryId() + validated = true } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun toBuilder() = Builder().from(this) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (initialQuantity.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (temporaryId.asKnown().isPresent) 1 else 0) - companion object { + class CollectionSchedule + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of [AddSpendTracker]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [AddSpendTracker]. */ - class Builder internal constructor() { + companion object { - private var alias: JsonField? = null - private var applicableSpendSpecifiers: - JsonField>? = - null - private var creditTypeId: JsonField? = null - private var resetFrequency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ADVANCE = of("ADVANCE") - @JvmSynthetic - internal fun from(addSpendTracker: AddSpendTracker) = apply { - alias = addSpendTracker.alias - applicableSpendSpecifiers = - addSpendTracker.applicableSpendSpecifiers.map { it.toMutableList() } - creditTypeId = addSpendTracker.creditTypeId - resetFrequency = addSpendTracker.resetFrequency - additionalProperties = addSpendTracker.additionalProperties.toMutableMap() + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - /** Human-readable identifier, unique per contract. */ - fun alias(alias: String) = alias(JsonField.of(alias)) + /** An enum containing [CollectionSchedule]'s known values. */ + enum class Known { + ADVANCE, + ARREARS, + } /** - * Sets [Builder.alias] to an arbitrary JSON value. + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * member. * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun alias(alias: JsonField) = apply { this.alias = alias } - - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: List - ) = applicableSpendSpecifiers(JsonField.of(applicableSpendSpecifiers)) + enum class Value { + ADVANCE, + ARREARS, + /** + * An enum member indicating that [CollectionSchedule] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.applicableSpendSpecifiers] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.applicableSpendSpecifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun applicableSpendSpecifiers( - applicableSpendSpecifiers: JsonField> - ) = apply { - this.applicableSpendSpecifiers = - applicableSpendSpecifiers.map { it.toMutableList() } - } + fun value(): Value = + when (this) { + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS + else -> Value._UNKNOWN + } /** - * Adds a single [ApplicableSpendSpecifier] to [applicableSpendSpecifiers]. + * Returns an enum member corresponding to this class instance's value. * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableSpendSpecifier(applicableSpendSpecifier: ApplicableSpendSpecifier) = - apply { - applicableSpendSpecifiers = - (applicableSpendSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableSpendSpecifiers", it) - .add(applicableSpendSpecifier) - } + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") } - fun creditTypeId(creditTypeId: String) = creditTypeId(JsonField.of(creditTypeId)) - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.creditTypeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun resetFrequency(resetFrequency: ResetFrequency) = - resetFrequency(JsonField.of(resetFrequency)) + private var validated: Boolean = false /** - * Sets [Builder.resetFrequency] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.resetFrequency] with a well-typed [ResetFrequency] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun resetFrequency(resetFrequency: JsonField) = apply { - this.resetFrequency = resetFrequency - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): CollectionSchedule = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddSpendTracker]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alias() - * .applicableSpendSpecifiers() - * .creditTypeId() - * .resetFrequency() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddSpendTracker = - AddSpendTracker( - checkRequired("alias", alias), - checkRequired("applicableSpendSpecifiers", applicableSpendSpecifiers).map { - it.toImmutable() - }, - checkRequired("creditTypeId", creditTypeId), - checkRequired("resetFrequency", resetFrequency), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddSpendTracker = apply { - if (validated) { - return@apply + return other is CollectionSchedule && value == other.value } - alias() - applicableSpendSpecifiers().forEach { it.validate() } - creditTypeId() - resetFrequency().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (alias.asKnown().isPresent) 1 else 0) + - (applicableSpendSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (resetFrequency.asKnown().getOrNull()?.validity() ?: 0) + override fun toString() = value.toString() + } - class ApplicableSpendSpecifier + class Proration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val sources: JsonField>, - private val spendType: JsonField, - private val discounted: JsonField, + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("sources") + @JsonProperty("invoice_behavior") @ExcludeMissing - sources: JsonField> = JsonMissing.of(), - @JsonProperty("spend_type") + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") @ExcludeMissing - spendType: JsonField = JsonMissing.of(), - @JsonProperty("discounted") + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") @ExcludeMissing - discounted: JsonField = JsonMissing.of(), - ) : this(sources, spendType, discounted, mutableMapOf()) + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun sources(): List = sources.getRequired("sources") + fun invoiceBehavior(): Optional = + invoiceBehavior.getOptional("invoice_behavior") /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Indicates if the partial period will be prorated or charged a full amount. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun spendType(): SpendType = spendType.getRequired("spend_type") + fun isProrated(): Optional = isProrated.getOptional("is_prorated") /** - * Filter by whether the spend was discounted. Defaults to ANY if omitted. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun discounted(): Optional = discounted.getOptional("discounted") + fun rounding(): Optional = rounding.getOptional("rounding") /** - * Returns the raw JSON value of [sources]. + * Returns the raw JSON value of [invoiceBehavior]. * - * Unlike [sources], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("sources") + @JsonProperty("invoice_behavior") @ExcludeMissing - fun _sources(): JsonField> = sources + fun _invoiceBehavior(): JsonField = invoiceBehavior /** - * Returns the raw JSON value of [spendType]. + * Returns the raw JSON value of [isProrated]. * - * Unlike [spendType], this method doesn't throw if the JSON field has an unexpected + * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("spend_type") + @JsonProperty("is_prorated") @ExcludeMissing - fun _spendType(): JsonField = spendType + fun _isProrated(): JsonField = isProrated /** - * Returns the raw JSON value of [discounted]. + * Returns the raw JSON value of [rounding]. * - * Unlike [discounted], this method doesn't throw if the JSON field has an unexpected + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("discounted") + @JsonProperty("rounding") @ExcludeMissing - fun _discounted(): JsonField = discounted + fun _rounding(): JsonField = rounding @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27339,87 +30724,70 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [ApplicableSpendSpecifier]. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Proration]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [ApplicableSpendSpecifier]. */ + /** A builder for [Proration]. */ class Builder internal constructor() { - private var sources: JsonField>? = null - private var spendType: JsonField? = null - private var discounted: JsonField = JsonMissing.of() + private var invoiceBehavior: JsonField = JsonMissing.of() + private var isProrated: JsonField = JsonMissing.of() + private var rounding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(applicableSpendSpecifier: ApplicableSpendSpecifier) = apply { - sources = applicableSpendSpecifier.sources.map { it.toMutableList() } - spendType = applicableSpendSpecifier.spendType - discounted = applicableSpendSpecifier.discounted - additionalProperties = - applicableSpendSpecifier.additionalProperties.toMutableMap() + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() } - fun sources(sources: List) = sources(JsonField.of(sources)) - /** - * Sets [Builder.sources] to an arbitrary JSON value. - * - * You should usually call [Builder.sources] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will + * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: + * The quantity increase will be billed for in-arrears at the end of the period. */ - fun sources(sources: JsonField>) = apply { - this.sources = sources.map { it.toMutableList() } - } + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) /** - * Adds a single [Source] to [sources]. + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addSource(source: Source) = apply { - sources = - (sources ?: JsonField.of(mutableListOf())).also { - checkKnown("sources", it).add(source) - } + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior } - fun spendType(spendType: SpendType) = spendType(JsonField.of(spendType)) + /** Indicates if the partial period will be prorated or charged a full amount. */ + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) /** - * Sets [Builder.spendType] to an arbitrary JSON value. + * Sets [Builder.isProrated] to an arbitrary JSON value. * - * You should usually call [Builder.spendType] with a well-typed [SpendType] value + * You should usually call [Builder.isProrated] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun spendType(spendType: JsonField) = apply { - this.spendType = spendType + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - fun discounted(discounted: Discounted) = discounted(JsonField.of(discounted)) + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) /** - * Sets [Builder.discounted] to an arbitrary JSON value. + * Sets [Builder.rounding] to an arbitrary JSON value. * - * You should usually call [Builder.discounted] with a well-typed [Discounted] value + * You should usually call [Builder.rounding] with a well-typed [Rounding] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun discounted(discounted: JsonField) = apply { - this.discounted = discounted - } + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -27444,23 +30812,15 @@ private constructor( } /** - * Returns an immutable instance of [ApplicableSpendSpecifier]. + * Returns an immutable instance of [Proration]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sources() - * .spendType() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ApplicableSpendSpecifier = - ApplicableSpendSpecifier( - checkRequired("sources", sources).map { it.toImmutable() }, - checkRequired("spendType", spendType), - discounted, + fun build(): Proration = + Proration( + invoiceBehavior, + isProrated, + rounding, additionalProperties.toMutableMap(), ) } @@ -27477,14 +30837,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ApplicableSpendSpecifier = apply { + fun validate(): Proration = apply { if (validated) { return@apply } - sources().forEach { it.validate() } - spendType().validate() - discounted().ifPresent { it.validate() } + invoiceBehavior().ifPresent { it.validate() } + isProrated() + rounding().ifPresent { it.validate() } validated = true } @@ -27504,12 +30864,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (sources.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (spendType.asKnown().getOrNull()?.validity() ?: 0) + - (discounted.asKnown().getOrNull()?.validity() ?: 0) + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - class Source @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: + * Only available when collection schedule is `ADVANCE`. The quantity increase will be + * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The + * quantity increase will be billed for in-arrears at the end of the period. + */ + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -27521,84 +30888,309 @@ private constructor( */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - companion object { + companion object { + + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + + @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } + + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } + + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceBehavior && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rounding]. */ + class Builder internal constructor() { - @JvmField val THRESHOLD_RECHARGE = of("THRESHOLD_RECHARGE") + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val MANUAL = of("MANUAL") + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** An enum containing [Source]'s known values. */ - enum class Known { - THRESHOLD_RECHARGE, - MANUAL, - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Source] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_RECHARGE, - MANUAL, /** - * An enum member indicating that [Source] was instantiated with an unknown - * value. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - _UNKNOWN, - } + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_RECHARGE -> Value.THRESHOLD_RECHARGE - MANUAL -> Value.MANUAL - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_RECHARGE -> Known.THRESHOLD_RECHARGE - MANUAL -> Known.MANUAL - else -> throw MetronomeInvalidDataException("Unknown Source: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -27611,12 +31203,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Source = apply { + fun validate(): Rounding = apply { if (validated) { return@apply } - known() + decimalPlaces() + roundingMethod().validate() validated = true } @@ -27634,413 +31227,380 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - return other is Source && value == other.value - } + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun hashCode() = value.hashCode() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun toString() = value.toString() - } + companion object { - class SpendType @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmField val FLOOR = of("FLOOR") - companion object { + @JvmField val CEILING = of("CEILING") - @JvmField val COMMIT_PURCHASE = of("COMMIT_PURCHASE") + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JvmStatic fun of(value: String) = SpendType(JsonField.of(value)) - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** An enum containing [SpendType]'s known values. */ - enum class Known { - COMMIT_PURCHASE - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * An enum containing [SpendType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [SpendType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_PURCHASE, /** - * An enum member indicating that [SpendType] was instantiated with an unknown - * value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - _UNKNOWN, - } + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_PURCHASE -> Value.COMMIT_PURCHASE - else -> Value._UNKNOWN - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_PURCHASE -> Known.COMMIT_PURCHASE - else -> throw MetronomeInvalidDataException("Unknown SpendType: $value") - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + private var validated: Boolean = false - private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): SpendType = apply { - if (validated) { - return@apply + known() + validated = true } - known() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is SpendType && value == other.value + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } - /** Filter by whether the spend was discounted. Defaults to ANY if omitted. */ - class Discounted - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - @JvmField val ANY = of("ANY") + override fun hashCode(): Int = hashCode - @JvmField val DISCOUNTED_ONLY = of("DISCOUNTED_ONLY") + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" + } - @JvmField val UNDISCOUNTED_ONLY = of("UNDISCOUNTED_ONLY") + class SubscriptionRate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingFrequency: JsonField, + private val productId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmStatic fun of(value: String) = Discounted(JsonField.of(value)) - } + @JsonCreator + private constructor( + @JsonProperty("billing_frequency") + @ExcludeMissing + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + ) : this(billingFrequency, productId, mutableMapOf()) - /** An enum containing [Discounted]'s known values. */ - enum class Known { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - } + /** + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") - /** - * An enum containing [Discounted]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Discounted] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANY, - DISCOUNTED_ONLY, - UNDISCOUNTED_ONLY, - /** - * An enum member indicating that [Discounted] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Must be subscription type product + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun productId(): String = productId.getRequired("product_id") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANY -> Value.ANY - DISCOUNTED_ONLY -> Value.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Value.UNDISCOUNTED_ONLY - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [billingFrequency]. + * + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_frequency") + @ExcludeMissing + fun _billingFrequency(): JsonField = billingFrequency - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANY -> Known.ANY - DISCOUNTED_ONLY -> Known.DISCOUNTED_ONLY - UNDISCOUNTED_ONLY -> Known.UNDISCOUNTED_ONLY - else -> throw MetronomeInvalidDataException("Unknown Discounted: $value") - } + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) + + companion object { /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` */ - fun validate(): Discounted = apply { - if (validated) { - return@apply - } + @JvmStatic fun builder() = Builder() + } - known() - validated = true + /** A builder for [SubscriptionRate]. */ + class Builder internal constructor() { + + private var billingFrequency: JsonField? = null + private var productId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + productId = subscriptionRate.productId + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Frequency to bill subscription with. Together with product_id, must match + * existing rate on the rate card. + */ + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Discounted && value == other.value + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency } - override fun hashCode() = value.hashCode() + /** Must be subscription type product */ + fun productId(productId: String) = productId(JsonField.of(productId)) - override fun toString() = value.toString() - } + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is ApplicableSpendSpecifier && - sources == other.sources && - spendType == other.spendType && - discounted == other.discounted && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(sources, spendType, discounted, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ApplicableSpendSpecifier{sources=$sources, spendType=$spendType, discounted=$discounted, additionalProperties=$additionalProperties}" - } - - class ResetFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmField val BILLING_PERIOD = of("BILLING_PERIOD") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic fun of(value: String) = ResetFrequency(JsonField.of(value)) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** An enum containing [ResetFrequency]'s known values. */ - enum class Known { - BILLING_PERIOD - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An enum containing [ResetFrequency]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ResetFrequency] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BILLING_PERIOD, /** - * An enum member indicating that [ResetFrequency] was instantiated with an unknown - * value. + * Returns an immutable instance of [SubscriptionRate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .productId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - _UNKNOWN, + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("productId", productId), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BILLING_PERIOD -> Value.BILLING_PERIOD - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BILLING_PERIOD -> Known.BILLING_PERIOD - else -> throw MetronomeInvalidDataException("Unknown ResetFrequency: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - private var validated: Boolean = false /** @@ -28053,710 +31613,713 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ResetFrequency = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - known() - validated = true - } + billingFrequency().validate() + productId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + /** + * Frequency to bill subscription with. Together with product_id, must match existing + * rate on the rate card. + */ + class BillingFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JvmField val MONTHLY = of("MONTHLY") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmField val QUARTERLY = of("QUARTERLY") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) } - return other is ResetFrequency && value == other.value - } + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } - override fun hashCode() = value.hashCode() + /** + * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [BillingFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - override fun toString() = value.toString() - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") + } - return other is AddSpendTracker && - alias == other.alias && - applicableSpendSpecifiers == other.applicableSpendSpecifiers && - creditTypeId == other.creditTypeId && - resetFrequency == other.resetFrequency && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - private val hashCode: Int by lazy { - Objects.hash( - alias, - applicableSpendSpecifiers, - creditTypeId, - resetFrequency, - additionalProperties, - ) - } + private var validated: Boolean = false - override fun hashCode(): Int = hashCode + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BillingFrequency = apply { + if (validated) { + return@apply + } - override fun toString() = - "AddSpendTracker{alias=$alias, applicableSpendSpecifiers=$applicableSpendSpecifiers, creditTypeId=$creditTypeId, resetFrequency=$resetFrequency, additionalProperties=$additionalProperties}" - } + known() + validated = true + } - class AddSubscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val subscriptionRate: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val initialQuantity: JsonField, - private val name: JsonField, - private val quantityManagementMode: JsonField, - private val seatConfig: JsonField, - private val startingAt: JsonField, - private val temporaryId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("initial_quantity") - @ExcludeMissing - initialQuantity: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("temporary_id") - @ExcludeMissing - temporaryId: JsonField = JsonMissing.of(), - ) : this( - collectionSchedule, - proration, - subscriptionRate, - customFields, - description, - endingBefore, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAt, - temporaryId, - mutableMapOf(), - ) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun proration(): Proration = proration.getRequired("proration") + return other is BillingFrequency && value == other.value + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun subscriptionRate(): SubscriptionRate = subscriptionRate.getRequired("subscription_rate") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + productId == other.productId && + additionalProperties == other.additionalProperties + } - /** - * Exclusive end time for the subscription. If not provided, subscription inherits contract - * end date. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + private val hashCode: Int by lazy { + Objects.hash(billingFrequency, productId, additionalProperties) + } - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun initialQuantity(): Optional = initialQuantity.getOptional("initial_quantity") + override fun hashCode(): Int = hashCode - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + override fun toString() = + "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" + } - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantityManagementMode(): Optional = - quantityManagementMode.getOptional("quantity_management_mode") + class BillingCycleConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + @JsonCreator + private constructor( + @JsonProperty("anchor_date") + @ExcludeMissing + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") + @ExcludeMissing + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) - /** - * Inclusive start time for the subscription. If not provided, defaults to contract start - * date - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + /** + * The date to anchor the billing cycle to. If omitted, defaults to the contract's usage + * invoice billing cycle anchor date. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun anchorDate(): Optional = anchorDate.getOptional("anchor_date") - /** - * A temporary ID used to reference the subscription in recurring commit/credit subscription - * configs created within the same payload. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun temporaryId(): Optional = temporaryId.getOptional("temporary_id") + /** + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoicePlacement(): Optional = + invoicePlacement.getOptional("invoice_placement") - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + /** + * Returns the raw JSON value of [anchorDate]. + * + * Unlike [anchorDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("anchor_date") + @ExcludeMissing + fun _anchorDate(): JsonField = anchorDate - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [invoicePlacement]. + * + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_placement") + @ExcludeMissing + fun _invoicePlacement(): JsonField = invoicePlacement - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + companion object { - /** - * Returns the raw JSON value of [initialQuantity]. - * - * Unlike [initialQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("initial_quantity") - @ExcludeMissing - fun _initialQuantity(): JsonField = initialQuantity + /** + * Returns a mutable builder for constructing an instance of [BillingCycleConfig]. + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [BillingCycleConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = quantityManagementMode + private var anchorDate: JsonField = JsonMissing.of() + private var invoicePlacement: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + @JvmSynthetic + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = billingCycleConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * The date to anchor the billing cycle to. If omitted, defaults to the contract's + * usage invoice billing cycle anchor date. + */ + fun anchorDate(anchorDate: OffsetDateTime) = anchorDate(JsonField.of(anchorDate)) - /** - * Returns the raw JSON value of [temporaryId]. - * - * Unlike [temporaryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("temporary_id") - @ExcludeMissing - fun _temporaryId(): JsonField = temporaryId + /** + * Sets [Builder.anchorDate] to an arbitrary JSON value. + * + * You should usually call [Builder.anchorDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Controls whether this subscription consolidates onto usage invoices or gets its + * own scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. + */ + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of [AddSubscription]. - * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [AddSubscription]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var subscriptionRate: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var initialQuantity: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantityManagementMode: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var temporaryId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(addSubscription: AddSubscription) = apply { - collectionSchedule = addSubscription.collectionSchedule - proration = addSubscription.proration - subscriptionRate = addSubscription.subscriptionRate - customFields = addSubscription.customFields - description = addSubscription.description - endingBefore = addSubscription.endingBefore - initialQuantity = addSubscription.initialQuantity - name = addSubscription.name - quantityManagementMode = addSubscription.quantityManagementMode - seatConfig = addSubscription.seatConfig - startingAt = addSubscription.startingAt - temporaryId = addSubscription.temporaryId - additionalProperties = addSubscription.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [BillingCycleConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BillingCycleConfig = + BillingCycleConfig( + anchorDate, + invoicePlacement, + additionalProperties.toMutableMap(), + ) } - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + private var validated: Boolean = false /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule + fun validate(): BillingCycleConfig = apply { + if (validated) { + return@apply + } + + anchorDate() + invoicePlacement().ifPresent { it.validate() } + validated = true } - fun proration(proration: Proration) = proration(JsonField.of(proration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.proration] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun proration(proration: JsonField) = apply { this.proration = proration } - - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + @JvmSynthetic + internal fun validity(): Int = + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Controls whether this subscription consolidates onto usage invoices or gets its own + * scheduled invoice. Defaults to ON_USAGE_INVOICE if omitted. */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + class InvoicePlacement + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = customFields(JsonField.of(customFields)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + companion object { - fun description(description: String) = description(JsonField.of(description)) + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") + + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) + } + + /** An enum containing [InvoicePlacement]'s known values. */ + enum class Known { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, + } + + /** + * An enum containing [InvoicePlacement]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoicePlacement] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, + /** + * An enum member indicating that [InvoicePlacement] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE + else -> + throw MetronomeInvalidDataException("Unknown InvoicePlacement: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): InvoicePlacement = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoicePlacement && value == other.value + } - /** - * Exclusive end time for the subscription. If not provided, subscription inherits - * contract end date. - */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + override fun toString() = value.toString() } - /** - * The initial quantity for the subscription. It must be non-negative value. Required if - * quantity_management_mode is QUANTITY_ONLY. - */ - fun initialQuantity(initialQuantity: Double) = - initialQuantity(JsonField.of(initialQuantity)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.initialQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.initialQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun initialQuantity(initialQuantity: JsonField) = apply { - this.initialQuantity = initialQuantity + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && + additionalProperties == other.additionalProperties } - fun name(name: String) = name(JsonField.of(name)) + private val hashCode: Int by lazy { + Objects.hash(anchorDate, invoicePlacement, additionalProperties) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + override fun hashCode(): Int = hashCode - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per - * seat. `seat_config` must be provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + override fun toString() = + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode(quantityManagementMode: JsonField) = - apply { - this.quantityManagementMode = quantityManagementMode - } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + fun toBuilder() = Builder().from(this) - /** - * Inclusive start time for the subscription. If not provided, defaults to contract - * start date - */ - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + companion object { - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + /** Returns a mutable builder for constructing an instance of [CustomFields]. */ + @JvmStatic fun builder() = Builder() } - /** - * A temporary ID used to reference the subscription in recurring commit/credit - * subscription configs created within the same payload. - */ - fun temporaryId(temporaryId: String) = temporaryId(JsonField.of(temporaryId)) + /** A builder for [CustomFields]. */ + class Builder internal constructor() { - /** - * Sets [Builder.temporaryId] to an arbitrary JSON value. - * - * You should usually call [Builder.temporaryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun temporaryId(temporaryId: JsonField) = apply { - this.temporaryId = temporaryId - } + private var additionalProperties: MutableMap = mutableMapOf() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) } + private var validated: Boolean = false + /** - * Returns an immutable instance of [AddSubscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .collectionSchedule() - * .proration() - * .subscriptionRate() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if any required field is unset. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun build(): AddSubscription = - AddSubscription( - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("subscriptionRate", subscriptionRate), - customFields, - description, - endingBefore, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAt, - temporaryId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun validate(): CustomFields = apply { + if (validated) { + return@apply + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddSubscription = apply { - if (validated) { - return@apply + validated = true } - collectionSchedule().validate() - proration().validate() - subscriptionRate().validate() - customFields().ifPresent { it.validate() } - description() - endingBefore() - initialQuantity() - name() - quantityManagementMode().ifPresent { it.validate() } - seatConfig().ifPresent { it.validate() } - startingAt() - temporaryId() - validated = true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFields && additionalProperties == other.additionalProperties } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. + * `initial_quantity` must be provided with this option. Compatible with recurring + * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass + * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription + * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** + * subscription to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. */ - @JvmSynthetic - internal fun validity(): Int = - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (initialQuantity.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (temporaryId.asKnown().isPresent) 1 else 0) - - class CollectionSchedule + class QuantityManagementMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -28772,24 +32335,24 @@ private constructor( companion object { - @JvmField val ADVANCE = of("ADVANCE") + @JvmField val SEAT_BASED = of("SEAT_BASED") - @JvmField val ARREARS = of("ARREARS") + @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) + @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) } - /** An enum containing [CollectionSchedule]'s known values. */ + /** An enum containing [QuantityManagementMode]'s known values. */ enum class Known { - ADVANCE, - ARREARS, + SEAT_BASED, + QUANTITY_ONLY, } /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * An enum containing [QuantityManagementMode]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * An instance of [QuantityManagementMode] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new @@ -28797,10 +32360,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - ADVANCE, - ARREARS, + SEAT_BASED, + QUANTITY_ONLY, /** - * An enum member indicating that [CollectionSchedule] was instantiated with an + * An enum member indicating that [QuantityManagementMode] was instantiated with an * unknown value. */ _UNKNOWN, @@ -28815,8 +32378,8 @@ private constructor( */ fun value(): Value = when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS + SEAT_BASED -> Value.SEAT_BASED + QUANTITY_ONLY -> Value.QUANTITY_ONLY else -> Value._UNKNOWN } @@ -28831,10 +32394,12 @@ private constructor( */ fun known(): Known = when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS + SEAT_BASED -> Known.SEAT_BASED + QUANTITY_ONLY -> Known.QUANTITY_ONLY else -> - throw MetronomeInvalidDataException("Unknown CollectionSchedule: $value") + throw MetronomeInvalidDataException( + "Unknown QuantityManagementMode: $value" + ) } /** @@ -28863,7 +32428,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): CollectionSchedule = apply { + fun validate(): QuantityManagementMode = apply { if (validated) { return@apply } @@ -28893,7 +32458,7 @@ private constructor( return true } - return other is CollectionSchedule && value == other.value + return other is QuantityManagementMode && value == other.value } override fun hashCode() = value.hashCode() @@ -28901,63 +32466,88 @@ private constructor( override fun toString() = value.toString() } - class Proration + class SeatConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val initialSeatIds: JsonField>, + private val seatGroupKey: JsonField, + private val initialUnassignedSeats: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("initial_seat_ids") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + initialSeatIds: JsonField> = JsonMissing.of(), + @JsonProperty("seat_group_key") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + seatGroupKey: JsonField = JsonMissing.of(), + @JsonProperty("initial_unassigned_seats") + @ExcludeMissing + initialUnassignedSeats: JsonField = JsonMissing.of(), + ) : this(initialSeatIds, seatGroupKey, initialUnassignedSeats, mutableMapOf()) /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. + * The initial assigned seats on this subscription. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun invoiceBehavior(): Optional = - invoiceBehavior.getOptional("invoice_behavior") + fun initialSeatIds(): List = initialSeatIds.getRequired("initial_seat_ids") /** - * Indicates if the partial period will be prorated or charged a full amount. + * The property name, sent on usage events, that identifies the seat ID associated with + * the usage event. For example, the property name might be seat_id or user_id. The + * property must be set as a group key on billable metrics and a presentation/pricing + * group key on contract products. This allows linked recurring credits with an + * allocation per seat to be consumed by only one seat's usage. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") + + /** + * The initial amount of unassigned seats on this subscription. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun isProrated(): Optional = isProrated.getOptional("is_prorated") + fun initialUnassignedSeats(): Optional = + initialUnassignedSeats.getOptional("initial_unassigned_seats") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [initialSeatIds]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [initialSeatIds], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("initial_seat_ids") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _initialSeatIds(): JsonField> = initialSeatIds /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [seatGroupKey]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an unexpected + * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("is_prorated") + @JsonProperty("seat_group_key") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _seatGroupKey(): JsonField = seatGroupKey + + /** + * Returns the raw JSON value of [initialUnassignedSeats]. + * + * Unlike [initialUnassignedSeats], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("initial_unassigned_seats") + @ExcludeMissing + fun _initialUnassignedSeats(): JsonField = initialUnassignedSeats @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28973,56 +32563,94 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Proration]. */ + /** + * Returns a mutable builder for constructing an instance of [SeatConfig]. + * + * The following fields are required: + * ```java + * .initialSeatIds() + * .seatGroupKey() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [SeatConfig]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField = JsonMissing.of() - private var isProrated: JsonField = JsonMissing.of() + private var initialSeatIds: JsonField>? = null + private var seatGroupKey: JsonField? = null + private var initialUnassignedSeats: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() + internal fun from(seatConfig: SeatConfig) = apply { + initialSeatIds = seatConfig.initialSeatIds.map { it.toMutableList() } + seatGroupKey = seatConfig.seatGroupKey + initialUnassignedSeats = seatConfig.initialUnassignedSeats + additionalProperties = seatConfig.additionalProperties.toMutableMap() } + /** The initial assigned seats on this subscription. */ + fun initialSeatIds(initialSeatIds: List) = + initialSeatIds(JsonField.of(initialSeatIds)) + /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will - * be billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: - * The quantity increase will be billed for in-arrears at the end of the period. + * Sets [Builder.initialSeatIds] to an arbitrary JSON value. + * + * You should usually call [Builder.initialSeatIds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + fun initialSeatIds(initialSeatIds: JsonField>) = apply { + this.initialSeatIds = initialSeatIds.map { it.toMutableList() } + } /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Adds a single [String] to [initialSeatIds]. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun addInitialSeatId(initialSeatId: String) = apply { + initialSeatIds = + (initialSeatIds ?: JsonField.of(mutableListOf())).also { + checkKnown("initialSeatIds", it).add(initialSeatId) + } } - /** Indicates if the partial period will be prorated or charged a full amount. */ - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * The property name, sent on usage events, that identifies the seat ID associated + * with the usage event. For example, the property name might be seat_id or user_id. + * The property must be set as a group key on billable metrics and a + * presentation/pricing group key on contract products. This allows linked recurring + * credits with an allocation per seat to be consumed by only one seat's usage. + */ + fun seatGroupKey(seatGroupKey: String) = seatGroupKey(JsonField.of(seatGroupKey)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.seatGroupKey] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] value + * You should usually call [Builder.seatGroupKey] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun seatGroupKey(seatGroupKey: JsonField) = apply { + this.seatGroupKey = seatGroupKey + } + + /** The initial amount of unassigned seats on this subscription. */ + fun initialUnassignedSeats(initialUnassignedSeats: Double) = + initialUnassignedSeats(JsonField.of(initialUnassignedSeats)) + + /** + * Sets [Builder.initialUnassignedSeats] to an arbitrary JSON value. + * + * You should usually call [Builder.initialUnassignedSeats] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun initialUnassignedSeats(initialUnassignedSeats: JsonField) = apply { + this.initialUnassignedSeats = initialUnassignedSeats } fun additionalProperties(additionalProperties: Map) = apply { @@ -29048,12 +32676,25 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [SeatConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .initialSeatIds() + * .seatGroupKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration(invoiceBehavior, isProrated, additionalProperties.toMutableMap()) + fun build(): SeatConfig = + SeatConfig( + checkRequired("initialSeatIds", initialSeatIds).map { it.toImmutable() }, + checkRequired("seatGroupKey", seatGroupKey), + initialUnassignedSeats, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -29068,13 +32709,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Proration = apply { + fun validate(): SeatConfig = apply { if (validated) { return@apply } - invoiceBehavior().ifPresent { it.validate() } - isProrated() + initialSeatIds() + seatGroupKey() + initialUnassignedSeats() validated = true } @@ -29094,1263 +32736,1330 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (initialSeatIds.asKnown().getOrNull()?.size ?: 0) + + (if (seatGroupKey.asKnown().isPresent) 1 else 0) + + (if (initialUnassignedSeats.asKnown().isPresent) 1 else 0) - /** - * Indicates how mid-period quantity adjustments are invoiced. **BILL_IMMEDIATELY**: - * Only available when collection schedule is `ADVANCE`. The quantity increase will be - * billed immediately on the scheduled date. **BILL_ON_NEXT_COLLECTION_DATE**: The - * quantity increase will be billed for in-arrears at the end of the period. - */ - class InvoiceBehavior - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is SeatConfig && + initialSeatIds == other.initialSeatIds && + seatGroupKey == other.seatGroupKey && + initialUnassignedSeats == other.initialUnassignedSeats && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + initialSeatIds, + seatGroupKey, + initialUnassignedSeats, + additionalProperties, + ) + } - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + override fun hashCode(): Int = hashCode - @JvmField val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + override fun toString() = + "SeatConfig{initialSeatIds=$initialSeatIds, seatGroupKey=$seatGroupKey, initialUnassignedSeats=$initialUnassignedSeats, additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** An enum containing [InvoiceBehavior]'s known values. */ - enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - } + return other is AddSubscription && + collectionSchedule == other.collectionSchedule && + proration == other.proration && + subscriptionRate == other.subscriptionRate && + billingCycleConfig == other.billingCycleConfig && + customFields == other.customFields && + description == other.description && + endingBefore == other.endingBefore && + initialQuantity == other.initialQuantity && + name == other.name && + quantityManagementMode == other.quantityManagementMode && + seatConfig == other.seatConfig && + startingAt == other.startingAt && + temporaryId == other.temporaryId && + additionalProperties == other.additionalProperties + } - /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + private val hashCode: Int by lazy { + Objects.hash( + collectionSchedule, + proration, + subscriptionRate, + billingCycleConfig, + customFields, + description, + endingBefore, + initialQuantity, + name, + quantityManagementMode, + seatConfig, + startingAt, + temporaryId, + additionalProperties, + ) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE - else -> Value._UNKNOWN - } + override fun hashCode(): Int = hashCode - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE - else -> - throw MetronomeInvalidDataException("Unknown InvoiceBehavior: $value") - } + override fun toString() = + "AddSubscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAt=$startingAt, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + class ArchiveCommit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - private var validated: Boolean = false + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): InvoiceBehavior = apply { - if (validated) { - return@apply - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - known() - validated = true - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ArchiveCommit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - return other is InvoiceBehavior && value == other.value - } + /** A builder for [ArchiveCommit]. */ + class Builder internal constructor() { - override fun hashCode() = value.hashCode() + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = value.toString() + @JvmSynthetic + internal fun from(archiveCommit: ArchiveCommit) = apply { + id = archiveCommit.id + additionalProperties = archiveCommit.additionalProperties.toMutableMap() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun id(id: String) = id(JsonField.of(id)) - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } - private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun hashCode(): Int = hashCode + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - class SubscriptionRate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val billingFrequency: JsonField, - private val productId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - @JsonCreator - private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - ) : this(billingFrequency, productId, mutableMapOf()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. + * Returns an immutable instance of [ArchiveCommit]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") - - /** - * Must be subscription type product + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun productId(): String = productId.getRequired("product_id") - - /** - * Returns the raw JSON value of [billingFrequency]. + * The following fields are required: + * ```java + * .id() + * ``` * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws IllegalStateException if any required field is unset. */ - @JsonProperty("billing_frequency") - @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency + fun build(): ArchiveCommit = + ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) + } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId + private var validated: Boolean = false - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ArchiveCommit = apply { + if (validated) { + return@apply } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + id() + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - /** - * Returns a mutable builder for constructing an instance of [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [SubscriptionRate]. */ - class Builder internal constructor() { + return other is ArchiveCommit && + id == other.id && + additionalProperties == other.additionalProperties + } - private var billingFrequency: JsonField? = null - private var productId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - productId = subscriptionRate.productId - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - /** - * Frequency to bill subscription with. Together with product_id, must match - * existing rate on the rate card. - */ - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + override fun toString() = + "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency - } + class ArchiveCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Must be subscription type product */ - fun productId(productId: String) = productId(JsonField.of(productId)) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ArchiveCredit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [ArchiveCredit]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an immutable instance of [SubscriptionRate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .productId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("productId", productId), - additionalProperties.toMutableMap(), - ) + @JvmSynthetic + internal fun from(archiveCredit: ArchiveCredit) = apply { + id = archiveCredit.id + additionalProperties = archiveCredit.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun id(id: String) = id(JsonField.of(id)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun validate(): SubscriptionRate = apply { - if (validated) { - return@apply - } + fun id(id: JsonField) = apply { this.id = id } - billingFrequency().validate() - productId() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [ArchiveCredit]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (productId.asKnown().isPresent) 1 else 0) + fun build(): ArchiveCredit = + ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) + } - /** - * Frequency to bill subscription with. Together with product_id, must match existing - * rate on the rate card. - */ - class BillingFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var validated: Boolean = false - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ArchiveCredit = apply { + if (validated) { + return@apply + } - companion object { + id() + validated = true + } - @JvmField val MONTHLY = of("MONTHLY") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val QUARTERLY = of("QUARTERLY") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - @JvmField val ANNUAL = of("ANNUAL") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val WEEKLY = of("WEEKLY") + return other is ArchiveCredit && + id == other.id && + additionalProperties == other.additionalProperties + } - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /** An enum containing [BillingFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + override fun hashCode(): Int = hashCode - /** - * An enum containing [BillingFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [BillingFrequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + override fun toString() = + "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + class ArchiveScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown BillingFrequency: $value") - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - private var validated: Boolean = false + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): BillingFrequency = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - known() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of [ArchiveScheduledCharge]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - return other is BillingFrequency && value == other.value - } + /** A builder for [ArchiveScheduledCharge]. */ + class Builder internal constructor() { - override fun hashCode() = value.hashCode() + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = value.toString() + @JvmSynthetic + internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { + id = archiveScheduledCharge.id + additionalProperties = archiveScheduledCharge.additionalProperties.toMutableMap() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun id(id: String) = id(JsonField.of(id)) - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - productId == other.productId && - additionalProperties == other.additionalProperties + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(billingFrequency, productId, additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun hashCode(): Int = hashCode + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, productId=$productId, additionalProperties=$additionalProperties}" + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ArchiveScheduledCharge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArchiveScheduledCharge = + ArchiveScheduledCharge(checkRequired("id", id), additionalProperties.toMutableMap()) } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ArchiveScheduledCharge = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + id() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + return other is ArchiveScheduledCharge && + id == other.id && + additionalProperties == other.additionalProperties + } - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun toString() = + "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class RemoveOverride + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveOverride]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveOverride]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeOverride: RemoveOverride) = apply { + id = removeOverride.id + additionalProperties = removeOverride.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun id(id: String) = id(JsonField.of(id)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + fun id(id: JsonField) = apply { this.id = id } - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [RemoveOverride]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + fun build(): RemoveOverride = + RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is CustomFields && additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemoveOverride = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + id() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveOverride && + id == other.id && + additionalProperties == other.additionalProperties } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" + } + + class UpdateCommit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commitId: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val invoiceSchedule: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("commit_id") + @ExcludeMissing + commitId: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") + @ExcludeMissing + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("invoice_schedule") + @ExcludeMissing + invoiceSchedule: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + ) : this( + commitId, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun commitId(): String = commitId.getRequired("commit_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") + + /** + * Which products the commit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags or + * specifiers are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Optional configuration for commit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceSchedule(): Optional = + invoiceSchedule.getOptional("invoice_schedule") + /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the subscription. - * `initial_quantity` must be provided with this option. Compatible with recurring - * commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you want to pass - * specific seat identifiers (e.g. add user_123) to increment and decrement a subscription - * quantity, rather than directly providing the quantity. You must use a **SEAT_BASED** - * subscription to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - class QuantityManagementMode - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun name(): Optional = name.getOptional("name") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - @JvmField val SEAT_BASED = of("SEAT_BASED") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + /** + * If provided, updates the commit to use the specified rate type for current and future + * invoices. Previously finalized invoices will need to be voided and regenerated to reflect + * the rate type change. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") - @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") - /** An enum containing [QuantityManagementMode]'s known values. */ - enum class Known { - SEAT_BASED, - QUANTITY_ONLY, - } + /** + * Returns the raw JSON value of [commitId]. + * + * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit_id") @ExcludeMissing fun _commitId(): JsonField = commitId - /** - * An enum containing [QuantityManagementMode]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [QuantityManagementMode] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEAT_BASED, - QUANTITY_ONLY, - /** - * An enum member indicating that [QuantityManagementMode] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEAT_BASED -> Value.SEAT_BASED - QUANTITY_ONLY -> Value.QUANTITY_ONLY - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SEAT_BASED -> Known.SEAT_BASED - QUANTITY_ONLY -> Known.QUANTITY_ONLY - else -> - throw MetronomeInvalidDataException( - "Unknown QuantityManagementMode: $value" - ) - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - private var validated: Boolean = false + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): QuantityManagementMode = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [invoiceSchedule]. + * + * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_schedule") + @ExcludeMissing + fun _invoiceSchedule(): JsonField = invoiceSchedule - known() - validated = true - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId - return other is QuantityManagementMode && value == other.value - } + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - override fun toString() = value.toString() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - class SeatConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val initialSeatIds: JsonField>, - private val seatGroupKey: JsonField, - private val initialUnassignedSeats: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonCreator - private constructor( - @JsonProperty("initial_seat_ids") - @ExcludeMissing - initialSeatIds: JsonField> = JsonMissing.of(), - @JsonProperty("seat_group_key") - @ExcludeMissing - seatGroupKey: JsonField = JsonMissing.of(), - @JsonProperty("initial_unassigned_seats") - @ExcludeMissing - initialUnassignedSeats: JsonField = JsonMissing.of(), - ) : this(initialSeatIds, seatGroupKey, initialUnassignedSeats, mutableMapOf()) + fun toBuilder() = Builder().from(this) - /** - * The initial assigned seats on this subscription. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun initialSeatIds(): List = initialSeatIds.getRequired("initial_seat_ids") + companion object { /** - * The property name, sent on usage events, that identifies the seat ID associated with - * the usage event. For example, the property name might be seat_id or user_id. The - * property must be set as a group key on billable metrics and a presentation/pricing - * group key on contract products. This allows linked recurring credits with an - * allocation per seat to be consumed by only one seat's usage. + * Returns a mutable builder for constructing an instance of [UpdateCommit]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * The following fields are required: + * ```java + * .commitId() + * ``` */ - fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") + @JvmStatic fun builder() = Builder() + } - /** - * The initial amount of unassigned seats on this subscription. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun initialUnassignedSeats(): Optional = - initialUnassignedSeats.getOptional("initial_unassigned_seats") + /** A builder for [UpdateCommit]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [initialSeatIds]. - * - * Unlike [initialSeatIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("initial_seat_ids") - @ExcludeMissing - fun _initialSeatIds(): JsonField> = initialSeatIds + private var commitId: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var invoiceSchedule: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateCommit: UpdateCommit) = apply { + commitId = updateCommit.commitId + accessSchedule = updateCommit.accessSchedule + applicableProductIds = updateCommit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCommit.applicableProductTags.map { it.toMutableList() } + description = updateCommit.description + hierarchyConfiguration = updateCommit.hierarchyConfiguration + invoiceSchedule = updateCommit.invoiceSchedule + name = updateCommit.name + netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId + priority = updateCommit.priority + productId = updateCommit.productId + rateType = updateCommit.rateType + rolloverFraction = updateCommit.rolloverFraction + additionalProperties = updateCommit.additionalProperties.toMutableMap() + } + + fun commitId(commitId: String) = commitId(JsonField.of(commitId)) /** - * Returns the raw JSON value of [seatGroupKey]. + * Sets [Builder.commitId] to an arbitrary JSON value. * - * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an unexpected - * type. + * You should usually call [Builder.commitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("seat_group_key") - @ExcludeMissing - fun _seatGroupKey(): JsonField = seatGroupKey + fun commitId(commitId: JsonField) = apply { this.commitId = commitId } + + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) /** - * Returns the raw JSON value of [initialUnassignedSeats]. + * Sets [Builder.accessSchedule] to an arbitrary JSON value. * - * Unlike [initialUnassignedSeats], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.accessSchedule] with a well-typed [AccessSchedule] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("initial_unassigned_seats") - @ExcludeMissing - fun _initialUnassignedSeats(): JsonField = initialUnassignedSeats - - @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 [SeatConfig]. - * - * The following fields are required: - * ```java - * .initialSeatIds() - * .seatGroupKey() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule } - /** A builder for [SeatConfig]. */ - class Builder internal constructor() { - - private var initialSeatIds: JsonField>? = null - private var seatGroupKey: JsonField? = null - private var initialUnassignedSeats: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(seatConfig: SeatConfig) = apply { - initialSeatIds = seatConfig.initialSeatIds.map { it.toMutableList() } - seatGroupKey = seatConfig.seatGroupKey - initialUnassignedSeats = seatConfig.initialUnassignedSeats - additionalProperties = seatConfig.additionalProperties.toMutableMap() - } - - /** The initial assigned seats on this subscription. */ - fun initialSeatIds(initialSeatIds: List) = - initialSeatIds(JsonField.of(initialSeatIds)) - - /** - * Sets [Builder.initialSeatIds] to an arbitrary JSON value. - * - * You should usually call [Builder.initialSeatIds] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun initialSeatIds(initialSeatIds: JsonField>) = apply { - this.initialSeatIds = initialSeatIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [initialSeatIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addInitialSeatId(initialSeatId: String) = apply { - initialSeatIds = - (initialSeatIds ?: JsonField.of(mutableListOf())).also { - checkKnown("initialSeatIds", it).add(initialSeatId) - } - } - - /** - * The property name, sent on usage events, that identifies the seat ID associated - * with the usage event. For example, the property name might be seat_id or user_id. - * The property must be set as a group key on billable metrics and a - * presentation/pricing group key on contract products. This allows linked recurring - * credits with an allocation per seat to be consumed by only one seat's usage. - */ - fun seatGroupKey(seatGroupKey: String) = seatGroupKey(JsonField.of(seatGroupKey)) - - /** - * Sets [Builder.seatGroupKey] to an arbitrary JSON value. - * - * You should usually call [Builder.seatGroupKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun seatGroupKey(seatGroupKey: JsonField) = apply { - this.seatGroupKey = seatGroupKey - } - - /** The initial amount of unassigned seats on this subscription. */ - fun initialUnassignedSeats(initialUnassignedSeats: Double) = - initialUnassignedSeats(JsonField.of(initialUnassignedSeats)) - - /** - * Sets [Builder.initialUnassignedSeats] to an arbitrary JSON value. - * - * You should usually call [Builder.initialUnassignedSeats] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun initialUnassignedSeats(initialUnassignedSeats: JsonField) = apply { - this.initialUnassignedSeats = initialUnassignedSeats - } + /** + * Which products the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) } + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the commit applies to all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - /** - * Returns an immutable instance of [SeatConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .initialSeatIds() - * .seatGroupKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SeatConfig = - SeatConfig( - checkRequired("initialSeatIds", initialSeatIds).map { it.toImmutable() }, - checkRequired("seatGroupKey", seatGroupKey), - initialUnassignedSeats, - additionalProperties.toMutableMap(), - ) + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } } - private var validated: Boolean = false - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Adds a single [String] to [applicableProductTags]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun validate(): SeatConfig = apply { - if (validated) { - return@apply - } - - initialSeatIds() - seatGroupKey() - initialUnassignedSeats() - validated = true + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun description(description: String) = description(JsonField.of(description)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.description] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (initialSeatIds.asKnown().getOrNull()?.size ?: 0) + - (if (seatGroupKey.asKnown().isPresent) 1 else 0) + - (if (initialUnassignedSeats.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SeatConfig && - initialSeatIds == other.initialSeatIds && - seatGroupKey == other.seatGroupKey && - initialUnassignedSeats == other.initialUnassignedSeats && - additionalProperties == other.additionalProperties + fun description(description: JsonField) = apply { + this.description = description } - private val hashCode: Int by lazy { - Objects.hash( - initialSeatIds, - seatGroupKey, - initialUnassignedSeats, - additionalProperties, - ) - } + /** Optional configuration for commit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - override fun toString() = - "SeatConfig{initialSeatIds=$initialSeatIds, seatGroupKey=$seatGroupKey, initialUnassignedSeats=$initialUnassignedSeats, additionalProperties=$additionalProperties}" - } + fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = + invoiceSchedule(JsonField.of(invoiceSchedule)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSchedule] with a well-typed [InvoiceSchedule] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun invoiceSchedule(invoiceSchedule: JsonField) = apply { + this.invoiceSchedule = invoiceSchedule } - return other is AddSubscription && - collectionSchedule == other.collectionSchedule && - proration == other.proration && - subscriptionRate == other.subscriptionRate && - customFields == other.customFields && - description == other.description && - endingBefore == other.endingBefore && - initialQuantity == other.initialQuantity && - name == other.name && - quantityManagementMode == other.quantityManagementMode && - seatConfig == other.seatConfig && - startingAt == other.startingAt && - temporaryId == other.temporaryId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - collectionSchedule, - proration, - subscriptionRate, - customFields, - description, - endingBefore, - initialQuantity, - name, - quantityManagementMode, - seatConfig, - startingAt, - temporaryId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode + fun name(name: String) = name(JsonField.of(name)) - override fun toString() = - "AddSubscription{collectionSchedule=$collectionSchedule, proration=$proration, subscriptionRate=$subscriptionRate, customFields=$customFields, description=$description, endingBefore=$endingBefore, initialQuantity=$initialQuantity, name=$name, quantityManagementMode=$quantityManagementMode, seatConfig=$seatConfig, startingAt=$startingAt, temporaryId=$temporaryId, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - class ArchiveCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - companion object { + fun productId(productId: String) = productId(JsonField.of(productId)) /** - * Returns a mutable builder for constructing an instance of [ArchiveCommit]. + * Sets [Builder.productId] to an arbitrary JSON value. * - * The following fields are required: - * ```java - * .id() - * ``` + * You should usually call [Builder.productId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmStatic fun builder() = Builder() - } + fun productId(productId: JsonField) = apply { this.productId = productId } - /** A builder for [ArchiveCommit]. */ - class Builder internal constructor() { + /** + * If provided, updates the commit to use the specified rate type for current and future + * invoices. Previously finalized invoices will need to be voided and regenerated to + * reflect the rate type change. + */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - @JvmSynthetic - internal fun from(archiveCommit: ArchiveCommit) = apply { - id = archiveCommit.id - additionalProperties = archiveCommit.additionalProperties.toMutableMap() - } + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) - fun id(id: String) = id(JsonField.of(id)) + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Alias for calling [Builder.rolloverFraction] with `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -30372,1584 +34081,1921 @@ private constructor( } /** - * Returns an immutable instance of [ArchiveCommit]. + * Returns an immutable instance of [UpdateCommit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() + * .commitId() * ``` * - * @throws IllegalStateException if any required field is unset. + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateCommit = + UpdateCommit( + checkRequired("commitId", commitId), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UpdateCommit = apply { + if (validated) { + return@apply + } + + commitId() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + invoiceSchedule().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (commitId.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + class AccessSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") + + /** + * Returns the raw JSON value of [addScheduleItems]. + * + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems + + /** + * Returns the raw JSON value of [removeScheduleItems]. + * + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = removeScheduleItems + + /** + * Returns the raw JSON value of [updateScheduleItems]. + * + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun build(): ArchiveCommit = - ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = updateScheduleItems - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ArchiveCommit = apply { - if (validated) { - return@apply + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - id() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Returns a mutable builder for constructing an instance of [AccessSchedule]. */ + @JvmStatic fun builder() = Builder() } - return other is ArchiveCommit && - id == other.id && - additionalProperties == other.additionalProperties - } + /** A builder for [AccessSchedule]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private var addScheduleItems: JsonField>? = null + private var removeScheduleItems: JsonField>? = null + private var updateScheduleItems: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun hashCode(): Int = hashCode + @JvmSynthetic + internal fun from(accessSchedule: AccessSchedule) = apply { + addScheduleItems = accessSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + accessSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + accessSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = accessSchedule.additionalProperties.toMutableMap() + } - override fun toString() = - "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" - } + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) - class ArchiveCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems(removeScheduleItems: JsonField>) = + apply { + this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems(updateScheduleItems: JsonField>) = + apply { + this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + } - companion object { + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } - /** - * Returns a mutable builder for constructing an instance of [ArchiveCredit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [ArchiveCredit]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmSynthetic - internal fun from(archiveCredit: ArchiveCredit) = apply { - id = archiveCredit.id - additionalProperties = archiveCredit.additionalProperties.toMutableMap() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessSchedule = + AccessSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun id(id: String) = id(JsonField.of(id)) + private var validated: Boolean = false /** - * Sets [Builder.id] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun id(id: JsonField) = apply { this.id = id } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): AccessSchedule = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [ArchiveCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): ArchiveCredit = - ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) - } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - private var validated: Boolean = false + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ArchiveCredit = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) - id() - validated = true - } + /** + * @throws MetronomeInvalidDataException if 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") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - return other is ArchiveCredit && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class ArchiveScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns a mutable builder for constructing an instance of [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + amount = addScheduleItem.amount + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt + additionalProperties = addScheduleItem.additionalProperties.toMutableMap() + } - fun toBuilder() = Builder().from(this) + fun amount(amount: Double) = amount(JsonField.of(amount)) - companion object { + /** + * 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 } - /** - * Returns a mutable builder for constructing an instance of [ArchiveScheduledCharge]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** A builder for [ArchiveScheduledCharge]. */ - class Builder internal constructor() { + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmSynthetic - internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { - id = archiveScheduledCharge.id - additionalProperties = archiveScheduledCharge.additionalProperties.toMutableMap() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + private var validated: Boolean = false - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + amount() + endingBefore() + startingAt() + validated = true + } - /** - * Returns an immutable instance of [ArchiveScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ArchiveScheduledCharge = - ArchiveScheduledCharge(checkRequired("id", id), additionalProperties.toMutableMap()) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - private var validated: Boolean = false + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ArchiveScheduledCharge = apply { - if (validated) { - return@apply - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - id() - validated = true - } + return other is AddScheduleItem && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private val hashCode: Int by lazy { + Objects.hash(amount, endingBefore, startingAt, additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun toString() = + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } - return other is ArchiveScheduledCharge && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - override fun toString() = - "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - class RemoveOverride - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun toBuilder() = Builder().from(this) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { - companion object { + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a mutable builder for constructing an instance of [RemoveOverride]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() + } - /** A builder for [RemoveOverride]. */ - class Builder internal constructor() { + fun id(id: String) = id(JsonField.of(id)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - @JvmSynthetic - internal fun from(removeOverride: RemoveOverride) = apply { - id = removeOverride.id - additionalProperties = removeOverride.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [RemoveOverride]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveOverride = - RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) - } + id() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): RemoveOverride = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - id() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" } - return other is RemoveOverride && - id == other.id && - additionalProperties == other.additionalProperties - } + class UpdateScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - override fun hashCode(): Int = hashCode + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - override fun toString() = - "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - class UpdateCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val commitId: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, - private val invoiceSchedule: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - @JsonCreator - private constructor( - @JsonProperty("commit_id") - @ExcludeMissing - commitId: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("invoice_schedule") - @ExcludeMissing - invoiceSchedule: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - ) : this( - commitId, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - mutableMapOf(), - ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): Optional = startingAt.getOptional("starting_at") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun commitId(): String = commitId.getRequired("commit_id") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") + /** + * 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 - /** - * Which products the commit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags or - * specifiers are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Optional configuration for commit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceSchedule(): Optional = - invoiceSchedule.getOptional("invoice_schedule") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + /** + * Returns a mutable builder for constructing an instance of + * [UpdateScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") + /** A builder for [UpdateScheduleItem]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * If provided, updates the commit to use the specified rate type for current and future - * invoices. Previously finalized invoices will need to be voided and regenerated to reflect - * the rate type change. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + @JvmSynthetic + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt + additionalProperties = + updateScheduleItem.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns the raw JSON value of [commitId]. - * - * Unlike [commitId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("commit_id") @ExcludeMissing fun _commitId(): JsonField = commitId + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + /** + * 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 } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Returns the raw JSON value of [invoiceSchedule]. - * - * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("invoice_schedule") - @ExcludeMissing - fun _invoiceSchedule(): JsonField = invoiceSchedule + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + /** + * Returns an immutable instance of [UpdateScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + endingBefore, + startingAt, + additionalProperties.toMutableMap(), + ) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): UpdateScheduleItem = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + id() + amount() + endingBefore() + startingAt() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns a mutable builder for constructing an instance of [UpdateCommit]. - * - * The following fields are required: - * ```java - * .commitId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - /** A builder for [UpdateCommit]. */ - class Builder internal constructor() { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var commitId: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var invoiceSchedule: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + return other is UpdateScheduleItem && + id == other.id && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - @JvmSynthetic - internal fun from(updateCommit: UpdateCommit) = apply { - commitId = updateCommit.commitId - accessSchedule = updateCommit.accessSchedule - applicableProductIds = updateCommit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCommit.applicableProductTags.map { it.toMutableList() } - description = updateCommit.description - hierarchyConfiguration = updateCommit.hierarchyConfiguration - invoiceSchedule = updateCommit.invoiceSchedule - name = updateCommit.name - netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId - priority = updateCommit.priority - productId = updateCommit.productId - rateType = updateCommit.rateType - rolloverFraction = updateCommit.rolloverFraction - additionalProperties = updateCommit.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) + } - fun commitId(commitId: String) = commitId(JsonField.of(commitId)) + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.commitId] to an arbitrary JSON value. - * - * You should usually call [Builder.commitId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun commitId(commitId: JsonField) = apply { this.commitId = commitId } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + return other is AccessSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.accessSchedule] with a well-typed [AccessSchedule] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) } - /** - * Which products the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + override fun toString() = + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } + + class InvoiceSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") /** - * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the commit applies to all products. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. + * Returns the raw JSON value of [addScheduleItems]. + * + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * Returns the raw JSON value of [removeScheduleItems]. * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = removeScheduleItems /** - * Adds a single [String] to [applicableProductTags]. + * Returns the raw JSON value of [updateScheduleItems]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = updateScheduleItems + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun description(description: String) = description(JsonField.of(description)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InvoiceSchedule]. */ + @JvmStatic fun builder() = Builder() } - /** Optional configuration for commit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + /** A builder for [InvoiceSchedule]. */ + class Builder internal constructor() { - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + private var addScheduleItems: JsonField>? = null + private var removeScheduleItems: JsonField>? = null + private var updateScheduleItems: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceSchedule: InvoiceSchedule) = apply { + addScheduleItems = invoiceSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + invoiceSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = invoiceSchedule.additionalProperties.toMutableMap() + } + + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) + + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } + + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) + + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems(removeScheduleItems: JsonField>) = + apply { + this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } + + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) + + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems(updateScheduleItems: JsonField>) = + apply { + this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + } - fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = - invoiceSchedule(JsonField.of(invoiceSchedule)) + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } - /** - * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceSchedule] with a well-typed [InvoiceSchedule] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun invoiceSchedule(invoiceSchedule: JsonField) = apply { - this.invoiceSchedule = invoiceSchedule - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun name(name: String) = name(JsonField.of(name)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId + /** + * Returns an immutable instance of [InvoiceSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceSchedule = + InvoiceSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + private var validated: Boolean = false /** - * Alias for [Builder.priority]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) - - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) - - /** - * Sets [Builder.priority] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * You should usually call [Builder.priority] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun priority(priority: JsonField) = apply { this.priority = priority } - - fun productId(productId: String) = productId(JsonField.of(productId)) + fun validate(): InvoiceSchedule = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** - * If provided, updates the commit to use the specified rate type for current and future - * invoices. Previously finalized invoices will need to be voided and regenerated to - * reflect the rate type change. - */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.rateType] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for [Builder.rolloverFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + @JsonCreator + private constructor( + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) - /** - * Alias for calling [Builder.rolloverFraction] with `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + /** + * @throws MetronomeInvalidDataException if 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") - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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 - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * 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 [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Returns an immutable instance of [UpdateCommit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .commitId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateCommit = - UpdateCommit( - checkRequired("commitId", commitId), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - additionalProperties.toMutableMap(), - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): UpdateCommit = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - commitId() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - invoiceSchedule().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (commitId.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - class AccessSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonCreator - private constructor( - @JsonProperty("add_schedule_items") - @ExcludeMissing - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") - @ExcludeMissing - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") - @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + timestamp = addScheduleItem.timestamp + amount = addScheduleItem.amount + quantity = addScheduleItem.quantity + unitPrice = addScheduleItem.unitPrice + additionalProperties = addScheduleItem.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + /** + * 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 + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + /** + * 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 } - /** - * Returns the raw JSON value of [removeScheduleItems]. - * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = removeScheduleItems + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - /** - * Returns the raw JSON value of [updateScheduleItems]. - * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("update_schedule_items") - @ExcludeMissing - fun _updateScheduleItems(): JsonField> = updateScheduleItems + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Returns a mutable builder for constructing an instance of [AccessSchedule]. */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [AccessSchedule]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var addScheduleItems: JsonField>? = null - private var removeScheduleItems: JsonField>? = null - private var updateScheduleItems: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = accessSchedule.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + private var validated: Boolean = false /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun addScheduleItems(addScheduleItems: JsonField>) = apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } + + timestamp() + amount() + quantity() + unitPrice() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Used for best match union deserialization. */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) - } + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties } - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + private val hashCode: Int by lazy { + Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun removeScheduleItems(removeScheduleItems: JsonField>) = - apply { - this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } - } + fun id(): String = id.getRequired("id") /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * Returns the raw JSON value of [id]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun updateScheduleItems(updateScheduleItems: JsonField>) = - apply { - this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + id() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AccessSchedule]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AccessSchedule = apply { - if (validated) { - return@apply + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties } - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" + } - class AddScheduleItem + class UpdateScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val id: JsonField, private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val quantity: JsonField, + private val timestamp: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + quantity: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") + fun id(): String = id.getRequired("id") /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + fun amount(): Optional = amount.getOptional("amount") /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): Optional = timestamp.getOptional("timestamp") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [amount]. @@ -31960,24 +36006,34 @@ private constructor( @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [quantity]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [timestamp]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("starting_at") + @JsonProperty("timestamp") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _timestamp(): JsonField = timestamp + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -31994,71 +36050,95 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AddScheduleItem]. + * Returns a mutable builder for constructing an instance of + * [UpdateScheduleItem]. * * The following fields are required: * ```java - * .amount() - * .endingBefore() - * .startingAt() + * .id() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddScheduleItem]. */ + /** A builder for [UpdateScheduleItem]. */ class Builder internal constructor() { - private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt - additionalProperties = addScheduleItem.additionalProperties.toMutableMap() + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + quantity = updateScheduleItem.quantity + timestamp = updateScheduleItem.timestamp + unitPrice = updateScheduleItem.unitPrice + additionalProperties = + updateScheduleItem.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + fun 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 + * 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 } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] 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 } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.timestamp] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed + * 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 endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = apply { @@ -32084,24 +36164,24 @@ private constructor( } /** - * Returns an immutable instance of [AddScheduleItem]. + * Returns an immutable instance of [UpdateScheduleItem]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .amount() - * .endingBefore() - * .startingAt() + * .id() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddScheduleItem = - AddScheduleItem( - checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + quantity, + timestamp, + unitPrice, additionalProperties.toMutableMap(), ) } @@ -32118,14 +36198,16 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): AddScheduleItem = apply { + fun validate(): UpdateScheduleItem = apply { if (validated) { return@apply } + id() amount() - endingBefore() - startingAt() + quantity() + timestamp() + unitPrice() validated = true } @@ -32145,524 +36227,926 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddScheduleItem && + return other is UpdateScheduleItem && + id == other.id && amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && + quantity == other.quantity && + timestamp == other.timestamp && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) + Objects.hash(id, amount, quantity, timestamp, unitPrice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } + + /** + * If provided, updates the commit to use the specified rate type for current and future + * invoices. Previously finalized invoices will need to be voided and regenerated to reflect + * the rate type change. + */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + LIST_RATE, + COMMIT_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST_RATE, + COMMIT_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode(): Int = hashCode + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateCommit && + commitId == other.commitId && + accessSchedule == other.accessSchedule && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceSchedule == other.invoiceSchedule && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + priority == other.priority && + productId == other.productId && + rateType == other.rateType && + rolloverFraction == other.rolloverFraction && + additionalProperties == other.additionalProperties + } - override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + private val hashCode: Int by lazy { + Objects.hash( + commitId, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + additionalProperties, + ) + } - class RemoveScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun hashCode(): Int = hashCode - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + override fun toString() = + "UpdateCommit{commitId=$commitId, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, additionalProperties=$additionalProperties}" + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + class UpdateCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditId: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonCreator + private constructor( + @JsonProperty("credit_id") + @ExcludeMissing + creditId: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") + @ExcludeMissing + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + ) : this( + creditId, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + mutableMapOf(), + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditId(): String = creditId.getRequired("credit_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") - fun toBuilder() = Builder().from(this) + /** + * Which products the credit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the credit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - companion object { + /** + * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags or + * specifiers are not provided, the credit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - /** - * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** A builder for [RemoveScheduleItem]. */ - class Builder internal constructor() { + /** + * Optional configuration for commit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id - additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - fun id(id: String) = id(JsonField.of(id)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If provided, updates the credit to use the specified rate type for current and future + * invoices. Previously finalized invoices will need to be voided and regenerated to reflect + * the rate type change. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [creditId]. + * + * Unlike [creditId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_id") @ExcludeMissing fun _creditId(): JsonField = creditId - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** - * Returns an immutable instance of [RemoveScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - private var validated: Boolean = false + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): RemoveScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration - id() - validated = true - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId - return other is RemoveScheduleItem && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * + * The following fields are required: + * ```java + * .creditId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + /** A builder for [UpdateCredit]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + private var creditId: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + @JvmSynthetic + internal fun from(updateCredit: UpdateCredit) = apply { + creditId = updateCredit.creditId + accessSchedule = updateCredit.accessSchedule + applicableProductIds = updateCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCredit.applicableProductTags.map { it.toMutableList() } + description = updateCredit.description + hierarchyConfiguration = updateCredit.hierarchyConfiguration + name = updateCredit.name + netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId + priority = updateCredit.priority + productId = updateCredit.productId + rateType = updateCredit.rateType + rolloverFraction = updateCredit.rolloverFraction + additionalProperties = updateCredit.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun creditId(creditId: String) = creditId(JsonField.of(creditId)) - /** - * 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 + /** + * Sets [Builder.creditId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditId(creditId: JsonField) = apply { this.creditId = creditId } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.accessSchedule] with a well-typed [AccessSchedule] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Which products the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - companion object { + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - /** - * Returns a mutable builder for constructing an instance of - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the credit applies to all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) } + } - fun id(id: String) = id(JsonField.of(id)) + fun description(description: String) = description(JsonField.of(description)) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - fun amount(amount: Double) = amount(JsonField.of(amount)) + /** Optional configuration for commit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - /** - * 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 } + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } + fun productId(productId: String) = productId(JsonField.of(productId)) - private var validated: Boolean = false + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + /** + * If provided, updates the credit to use the specified rate type for current and future + * invoices. Previously finalized invoices will need to be voided and regenerated to + * reflect the rate type change. + */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.rolloverFraction] with `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun hashCode(): Int = hashCode + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, + /** + * Returns an immutable instance of [UpdateCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateCredit = + UpdateCredit( + checkRequired("creditId", creditId), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + additionalProperties.toMutableMap(), ) - } + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UpdateCredit = apply { + if (validated) { + return@apply + } + + creditId() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + validated = true } - class InvoiceSchedule + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditId.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + class AccessSchedule @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val addScheduleItems: JsonField>, @@ -32749,11 +37233,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [InvoiceSchedule]. */ + /** Returns a mutable builder for constructing an instance of [AccessSchedule]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoiceSchedule]. */ + /** A builder for [AccessSchedule]. */ class Builder internal constructor() { private var addScheduleItems: JsonField>? = null @@ -32762,13 +37246,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(invoiceSchedule: InvoiceSchedule) = apply { - addScheduleItems = invoiceSchedule.addScheduleItems.map { it.toMutableList() } + internal fun from(accessSchedule: AccessSchedule) = apply { + addScheduleItems = accessSchedule.addScheduleItems.map { it.toMutableList() } removeScheduleItems = - invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + accessSchedule.removeScheduleItems.map { it.toMutableList() } updateScheduleItems = - invoiceSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = invoiceSchedule.additionalProperties.toMutableMap() + accessSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = accessSchedule.additionalProperties.toMutableMap() } fun addScheduleItems(addScheduleItems: List) = @@ -32874,12 +37358,12 @@ private constructor( } /** - * Returns an immutable instance of [InvoiceSchedule]. + * Returns an immutable instance of [AccessSchedule]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): InvoiceSchedule = - InvoiceSchedule( + fun build(): AccessSchedule = + AccessSchedule( (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, @@ -32899,7 +37383,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): InvoiceSchedule = apply { + fun validate(): AccessSchedule = apply { if (validated) { return@apply } @@ -32935,63 +37419,45 @@ private constructor( class AddScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val timestamp: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun amount(): Double = amount.getRequired("amount") /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") /** - * Returns the raw JSON value of [timestamp]. - * - * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("timestamp") - @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") /** * Returns the raw JSON value of [amount]. @@ -33002,24 +37468,24 @@ private constructor( @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - fun _quantity(): JsonField = quantity + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -33040,7 +37506,9 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -33049,34 +37517,19 @@ private constructor( /** A builder for [AddScheduleItem]. */ class Builder internal constructor() { - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addScheduleItem: AddScheduleItem) = apply { - timestamp = addScheduleItem.timestamp amount = addScheduleItem.amount - quantity = addScheduleItem.quantity - unitPrice = addScheduleItem.unitPrice + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt additionalProperties = addScheduleItem.additionalProperties.toMutableMap() } - 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 - } - fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -33088,28 +37541,32 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = apply { @@ -33141,17 +37598,18 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AddScheduleItem = AddScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), additionalProperties.toMutableMap(), ) } @@ -33173,10 +37631,9 @@ private constructor( return@apply } - timestamp() amount() - quantity() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -33196,10 +37653,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -33207,21 +37663,20 @@ private constructor( } return other is AddScheduleItem && - timestamp == other.timestamp && amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + Objects.hash(amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } class RemoveScheduleItem @@ -33401,9 +37856,8 @@ private constructor( private constructor( private val id: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val timestamp: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -33413,16 +37867,13 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("timestamp") + @JsonProperty("ending_before") @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or @@ -33441,19 +37892,14 @@ private constructor( * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun timestamp(): Optional = timestamp.getOptional("timestamp") + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun startingAt(): Optional = startingAt.getOptional("starting_at") /** * Returns the raw JSON value of [id]. @@ -33471,34 +37917,24 @@ private constructor( @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [timestamp]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("timestamp") + @JsonProperty("ending_before") @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -33531,18 +37967,16 @@ private constructor( private var id: JsonField? = null private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var timestamp: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { id = updateScheduleItem.id amount = updateScheduleItem.amount - quantity = updateScheduleItem.quantity - timestamp = updateScheduleItem.timestamp - unitPrice = updateScheduleItem.unitPrice + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt additionalProperties = updateScheduleItem.additionalProperties.toMutableMap() } @@ -33569,41 +38003,32 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.timestamp] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.timestamp] with a well-typed + * You should usually call [Builder.endingBefore] 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 + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = apply { @@ -33644,9 +38069,8 @@ private constructor( UpdateScheduleItem( checkRequired("id", id), amount, - quantity, - timestamp, - unitPrice, + endingBefore, + startingAt, additionalProperties.toMutableMap(), ) } @@ -33670,9 +38094,8 @@ private constructor( id() amount() - quantity() - timestamp() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -33694,9 +38117,8 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -33706,20 +38128,19 @@ private constructor( return other is UpdateScheduleItem && id == other.id && amount == other.amount && - quantity == other.quantity && - timestamp == other.timestamp && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, amount, quantity, timestamp, unitPrice, additionalProperties) + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -33727,7 +38148,7 @@ private constructor( return true } - return other is InvoiceSchedule && + return other is AccessSchedule && addScheduleItems == other.addScheduleItems && removeScheduleItems == other.removeScheduleItems && updateScheduleItems == other.updateScheduleItems && @@ -33746,11 +38167,11 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" } /** - * If provided, updates the commit to use the specified rate type for current and future + * If provided, updates the credit to use the specified rate type for current and future * invoices. Previously finalized invoices will need to be voided and regenerated to reflect * the rate type change. */ @@ -33899,14 +38320,13 @@ private constructor( return true } - return other is UpdateCommit && - commitId == other.commitId && + return other is UpdateCredit && + creditId == other.creditId && accessSchedule == other.accessSchedule && applicableProductIds == other.applicableProductIds && applicableProductTags == other.applicableProductTags && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && - invoiceSchedule == other.invoiceSchedule && name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && priority == other.priority && @@ -33918,13 +38338,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - commitId, + creditId, accessSchedule, applicableProductIds, applicableProductTags, description, hierarchyConfiguration, - invoiceSchedule, name, netsuiteSalesOrderId, priority, @@ -33938,751 +38357,1099 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateCommit{commitId=$commitId, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, additionalProperties=$additionalProperties}" + "UpdateCredit{creditId=$creditId, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, additionalProperties=$additionalProperties}" } - class UpdateCredit + class UpdatePrepaidBalanceThresholdConfiguration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val creditId: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, + private val commit: JsonField, + private val customCreditTypeId: JsonField, + private val discountConfiguration: JsonField, + private val isEnabled: JsonField, + private val paymentGateConfig: JsonField, + private val rechargeToAmount: JsonField, + private val thresholdAmount: JsonField, + private val thresholdBalanceSpecifiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("credit_id") - @ExcludeMissing - creditId: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + @JsonProperty("custom_credit_type_id") @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") + customCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("discount_configuration") @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") + discountConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("is_enabled") @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") + isEnabled: JsonField = JsonMissing.of(), + @JsonProperty("payment_gate_config") @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") + paymentGateConfig: JsonField = JsonMissing.of(), + @JsonProperty("recharge_to_amount") @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") + rechargeToAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_balance_specifiers") @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), + thresholdBalanceSpecifiers: JsonField> = + JsonMissing.of(), ) : this( - creditId, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, mutableMapOf(), ) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun commit(): Optional = commit.getOptional("commit") + + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold commit amount + * will be in terms of this credit type instead of the fiat currency. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCreditTypeId(): Optional = + customCreditTypeId.getOptional("custom_credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun discountConfiguration(): Optional = + discountConfiguration.getOptional("discount_configuration") + + /** + * When set to false, the contract will not be evaluated against the threshold_amount. + * Toggling to true will result an immediate evaluation, regardless of prior state. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun paymentGateConfig(): Optional = + paymentGateConfig.getOptional("payment_gate_config") + + /** + * Specify the amount the balance should be recharged to. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rechargeToAmount(): Optional = + rechargeToAmount.getOptional("recharge_to_amount") + + /** + * Specify the threshold amount for the contract. Each time the contract's balance lowers to + * this amount, a threshold charge will be initiated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thresholdAmount(): Optional = thresholdAmount.getOptional("threshold_amount") + + /** + * Determines which balances are excluded from remaining balance calculation for threshold + * billing. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thresholdBalanceSpecifiers(): Optional> = + thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + /** + * Returns the raw JSON value of [customCreditTypeId]. + * + * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_credit_type_id") + @ExcludeMissing + fun _customCreditTypeId(): JsonField = customCreditTypeId + + /** + * Returns the raw JSON value of [discountConfiguration]. + * + * Unlike [discountConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun creditId(): String = creditId.getRequired("credit_id") + @JsonProperty("discount_configuration") + @ExcludeMissing + fun _discountConfiguration(): JsonField = discountConfiguration /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") + @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField = isEnabled /** - * Which products the credit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the credit applies to all products. + * Returns the raw JSON value of [paymentGateConfig]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + @JsonProperty("payment_gate_config") + @ExcludeMissing + fun _paymentGateConfig(): JsonField = paymentGateConfig /** - * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags or - * specifiers are not provided, the credit applies to all products. + * Returns the raw JSON value of [rechargeToAmount]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + @JsonProperty("recharge_to_amount") + @ExcludeMissing + fun _rechargeToAmount(): JsonField = rechargeToAmount /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun description(): Optional = description.getOptional("description") + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount /** - * Optional configuration for commit hierarchy access control + * Returns the raw JSON value of [thresholdBalanceSpecifiers]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + @JsonProperty("threshold_balance_specifiers") + @ExcludeMissing + fun _thresholdBalanceSpecifiers(): JsonField> = + thresholdBalanceSpecifiers + + @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 + * [UpdatePrepaidBalanceThresholdConfiguration]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + class Builder internal constructor() { + + private var commit: JsonField = JsonMissing.of() + private var customCreditTypeId: JsonField = JsonMissing.of() + private var discountConfiguration: JsonField = JsonMissing.of() + private var isEnabled: JsonField = JsonMissing.of() + private var paymentGateConfig: JsonField = JsonMissing.of() + private var rechargeToAmount: JsonField = JsonMissing.of() + private var thresholdAmount: JsonField = JsonMissing.of() + private var thresholdBalanceSpecifiers: + JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + updatePrepaidBalanceThresholdConfiguration: + UpdatePrepaidBalanceThresholdConfiguration + ) = apply { + commit = updatePrepaidBalanceThresholdConfiguration.commit + customCreditTypeId = updatePrepaidBalanceThresholdConfiguration.customCreditTypeId + discountConfiguration = + updatePrepaidBalanceThresholdConfiguration.discountConfiguration + isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled + paymentGateConfig = updatePrepaidBalanceThresholdConfiguration.paymentGateConfig + rechargeToAmount = updatePrepaidBalanceThresholdConfiguration.rechargeToAmount + thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount + thresholdBalanceSpecifiers = + updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers.map { + it.toMutableList() + } + additionalProperties = + updatePrepaidBalanceThresholdConfiguration.additionalProperties.toMutableMap() + } + + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold commit + * amount will be in terms of this credit type instead of the fiat currency. + */ + fun customCreditTypeId(customCreditTypeId: String?) = + customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) + + /** + * Alias for calling [Builder.customCreditTypeId] with + * `customCreditTypeId.orElse(null)`. + */ + fun customCreditTypeId(customCreditTypeId: Optional) = + customCreditTypeId(customCreditTypeId.getOrNull()) + + /** + * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.customCreditTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCreditTypeId(customCreditTypeId: JsonField) = apply { + this.customCreditTypeId = customCreditTypeId + } + + fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = + discountConfiguration(JsonField.ofNullable(discountConfiguration)) + + /** + * Alias for calling [Builder.discountConfiguration] with + * `discountConfiguration.orElse(null)`. + */ + fun discountConfiguration(discountConfiguration: Optional) = + discountConfiguration(discountConfiguration.getOrNull()) + + /** + * Sets [Builder.discountConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.discountConfiguration] with a well-typed + * [DiscountConfiguration] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountConfiguration(discountConfiguration: JsonField) = + apply { + this.discountConfiguration = discountConfiguration + } + + /** + * When set to false, the contract will not be evaluated against the threshold_amount. + * Toggling to true will result an immediate evaluation, regardless of prior state. + */ + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + + /** + * Sets [Builder.isEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isEnabled(isEnabled: JsonField) = apply { this.isEnabled = isEnabled } + + fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = + paymentGateConfig(JsonField.of(paymentGateConfig)) + + /** + * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentGateConfig] with a well-typed + * [PaymentGateConfigV2] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentGateConfig(paymentGateConfig: JsonField) = apply { + this.paymentGateConfig = paymentGateConfig + } + + /** Specify the amount the balance should be recharged to. */ + fun rechargeToAmount(rechargeToAmount: Double) = + rechargeToAmount(JsonField.of(rechargeToAmount)) + + /** + * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rechargeToAmount(rechargeToAmount: JsonField) = apply { + this.rechargeToAmount = rechargeToAmount + } + + /** + * Specify the threshold amount for the contract. Each time the contract's balance + * lowers to this amount, a threshold charge will be initiated. + */ + fun thresholdAmount(thresholdAmount: Double) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + /** + * Determines which balances are excluded from remaining balance calculation for + * threshold billing. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: List? + ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) + + /** + * Alias for calling [Builder.thresholdBalanceSpecifiers] with + * `thresholdBalanceSpecifiers.orElse(null)`. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: Optional> + ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + /** + * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdBalanceSpecifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: JsonField> + ) = apply { + this.thresholdBalanceSpecifiers = + thresholdBalanceSpecifiers.map { it.toMutableList() } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + /** + * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdBalanceSpecifier(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = + apply { + thresholdBalanceSpecifiers = + (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdBalanceSpecifiers", it) + .add(thresholdBalanceSpecifier) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * If provided, updates the credit to use the specified rate type for current and future - * invoices. Previously finalized invoices will need to be voided and regenerated to reflect - * the rate type change. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = rolloverFraction.getOptional("rollover_fraction") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [creditId]. - * - * Unlike [creditId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("credit_id") @ExcludeMissing fun _creditId(): JsonField = creditId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule + /** + * Returns an immutable instance of [UpdatePrepaidBalanceThresholdConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdatePrepaidBalanceThresholdConfiguration = + UpdatePrepaidBalanceThresholdConfiguration( + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + private var validated: Boolean = false /** - * Returns the raw JSON value of [applicableProductTags]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags - - /** - * Returns the raw JSON value of [description]. + * This method is _not_ forwards compatible with new types from the API for existing fields. * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + commit().ifPresent { it.validate() } + customCreditTypeId() + discountConfiguration().ifPresent { it.validate() } + isEnabled() + paymentGateConfig().ifPresent { it.validate() } + rechargeToAmount() + thresholdAmount() + thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + @JvmSynthetic + internal fun validity(): Int = + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + + (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + class Commit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val name: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + description, + name, + priority, + productId, + applicableProductIds, + applicableProductTags, + specifiers, + mutableMapOf(), + ) + + fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = + UpdateBaseThresholdCommit.builder() + .description(description) + .name(name) + .priority(priority) + .productId(productId) + .build() - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + /** + * Specify the name of the line item for the threshold charge. If left blank, it will + * default to the commit product name. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The priority of the commit, used to determine drawdown order. Lower priority commits + * are consumed first. Defaults to 100 if not specified. On updates, set to null to + * clear a previously configured priority. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The commit product that will be used to generate the line item for commit payment. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - fun toBuilder() = Builder().from(this) + /** + * Which products the threshold commit applies to. If both applicable_product_ids and + * applicable_product_tags are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - companion object { + /** + * Which tags the threshold commit applies to. If both applicable_product_ids and + * applicable_product_tags are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") /** - * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to + * target usage by product or product tag, pass those values in the body of + * `specifiers`. * - * The following fields are required: - * ```java - * .creditId() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JvmStatic fun builder() = Builder() - } + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") - /** A builder for [UpdateCredit]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - private var creditId: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(updateCredit: UpdateCredit) = apply { - creditId = updateCredit.creditId - accessSchedule = updateCredit.accessSchedule - applicableProductIds = updateCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCredit.applicableProductTags.map { it.toMutableList() } - description = updateCredit.description - hierarchyConfiguration = updateCredit.hierarchyConfiguration - name = updateCredit.name - netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId - priority = updateCredit.priority - productId = updateCredit.productId - rateType = updateCredit.rateType - rolloverFraction = updateCredit.rolloverFraction - additionalProperties = updateCredit.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority - fun creditId(creditId: String) = creditId(JsonField.of(creditId)) + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId /** - * Sets [Builder.creditId] to an arbitrary JSON value. + * Returns the raw JSON value of [applicableProductIds]. * - * You should usually call [Builder.creditId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun creditId(creditId: JsonField) = apply { this.creditId = creditId } + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * Returns the raw JSON value of [specifiers]. * - * You should usually call [Builder.accessSchedule] with a well-typed [AccessSchedule] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + @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 [Commit]. */ + @JvmStatic fun builder() = Builder() } - /** - * Which products the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + description = commit.description + name = commit.name + priority = commit.priority + productId = commit.productId + applicableProductIds = commit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = commit.applicableProductTags.map { it.toMutableList() } + specifiers = commit.specifiers.map { it.toMutableList() } + additionalProperties = commit.additionalProperties.toMutableMap() + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Specify the name of the line item for the threshold charge. If left blank, it + * will default to the commit product name. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The priority of the commit, used to determine drawdown order. Lower priority + * commits are consumed first. Defaults to 100 if not specified. On updates, set to + * null to clear a previously configured priority. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - /** - * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the credit applies to all products. - */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + /** + * The commit product that will be used to generate the line item for commit + * payment. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + /** + * Which products the threshold commit applies to. If both applicable_product_ids + * and applicable_product_tags are not provided, the commit applies to all products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } - } + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - fun description(description: String) = description(JsonField.of(description)) + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - /** Optional configuration for commit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + /** + * Which tags the threshold commit applies to. If both applicable_product_ids and + * applicable_product_tags are not provided, the commit applies to all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun productId(productId: String) = productId(JsonField.of(productId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } + /** + * Returns an immutable instance of [Commit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Commit = + Commit( + description, + name, + priority, + productId, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * If provided, updates the credit to use the specified rate type for current and future - * invoices. Previously finalized invoices will need to be voided and regenerated to - * reflect the rate type change. - */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + private var validated: Boolean = false /** - * Sets [Builder.rateType] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) - - /** - * Alias for [Builder.rolloverFraction]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * This unboxed primitive overload exists for backwards compatibility. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + fun validate(): Commit = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [Builder.rolloverFraction] with `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + description() + name() + priority() + productId() + applicableProductIds() + applicableProductTags() + specifiers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + return other is Commit && + description == other.description && + name == other.name && + priority == other.priority && + productId == other.productId && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + specifiers == other.specifiers && + additionalProperties == other.additionalProperties } - /** - * Returns an immutable instance of [UpdateCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateCredit = - UpdateCredit( - checkRequired("creditId", creditId), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + private val hashCode: Int by lazy { + Objects.hash( description, - hierarchyConfiguration, name, - netsuiteSalesOrderId, priority, productId, - rateType, - rolloverFraction, - 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 MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): UpdateCredit = apply { - if (validated) { - return@apply - } - - creditId() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditId.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + applicableProductIds, + applicableProductTags, + specifiers, + additionalProperties, + ) + } - class AccessSchedule + override fun hashCode(): Int = hashCode + + override fun toString() = + "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" + } + + class DiscountConfiguration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, + private val cap: JsonField, + private val paymentFraction: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("add_schedule_items") - @ExcludeMissing - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") - @ExcludeMissing - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") + @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), + @JsonProperty("payment_fraction") @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + paymentFraction: JsonField = JsonMissing.of(), + ) : this(cap, paymentFraction, mutableMapOf()) /** + * Update the discount cap. Set to null to remove an existing cap. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + fun cap(): Optional = cap.getOptional("cap") /** + * The fraction of the original amount that the customer pays after applying the + * discount. Set to null to remove the discount fraction. For example, 0.85 means the + * customer pays 85% of the original amount (a 15% discount). + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") - - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + fun paymentFraction(): Optional = + paymentFraction.getOptional("payment_fraction") /** - * Returns the raw JSON value of [removeScheduleItems]. + * Returns the raw JSON value of [cap]. * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cap], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = removeScheduleItems + @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap /** - * Returns the raw JSON value of [updateScheduleItems]. + * Returns the raw JSON value of [paymentFraction]. * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an + * Unlike [paymentFraction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("update_schedule_items") + @JsonProperty("payment_fraction") @ExcludeMissing - fun _updateScheduleItems(): JsonField> = updateScheduleItems + fun _paymentFraction(): JsonField = paymentFraction @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -34698,106 +39465,73 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [AccessSchedule]. */ + /** + * Returns a mutable builder for constructing an instance of + * [DiscountConfiguration]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [AccessSchedule]. */ + /** A builder for [DiscountConfiguration]. */ class Builder internal constructor() { - private var addScheduleItems: JsonField>? = null - private var removeScheduleItems: JsonField>? = null - private var updateScheduleItems: JsonField>? = null + private var cap: JsonField = JsonMissing.of() + private var paymentFraction: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = accessSchedule.additionalProperties.toMutableMap() + internal fun from(discountConfiguration: DiscountConfiguration) = apply { + cap = discountConfiguration.cap + paymentFraction = discountConfiguration.paymentFraction + additionalProperties = discountConfiguration.additionalProperties.toMutableMap() } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + /** Update the discount cap. Set to null to remove an existing cap. */ + fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addScheduleItems(addScheduleItems: JsonField>) = apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } - } + /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ + fun cap(cap: Optional) = cap(cap.getOrNull()) /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. + * Sets [Builder.cap] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.cap] with a well-typed [Cap] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) - } - } - - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + fun cap(cap: JsonField) = apply { this.cap = cap } /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * The fraction of the original amount that the customer pays after applying the + * discount. Set to null to remove the discount fraction. For example, 0.85 means + * the customer pays 85% of the original amount (a 15% discount). */ - fun removeScheduleItems(removeScheduleItems: JsonField>) = - apply { - this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } - } + fun paymentFraction(paymentFraction: Double?) = + paymentFraction(JsonField.ofNullable(paymentFraction)) /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * Alias for [Builder.paymentFraction]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This unboxed primitive overload exists for backwards compatibility. */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) - } - } - - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + fun paymentFraction(paymentFraction: Double) = + paymentFraction(paymentFraction as Double?) /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Alias for calling [Builder.paymentFraction] with `paymentFraction.orElse(null)`. */ - fun updateScheduleItems(updateScheduleItems: JsonField>) = - apply { - this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } - } + fun paymentFraction(paymentFraction: Optional) = + paymentFraction(paymentFraction.getOrNull()) /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * Sets [Builder.paymentFraction] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.paymentFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } + fun paymentFraction(paymentFraction: JsonField) = apply { + this.paymentFraction = paymentFraction } fun additionalProperties(additionalProperties: Map) = apply { @@ -34823,17 +39557,12 @@ private constructor( } /** - * Returns an immutable instance of [AccessSchedule]. + * Returns an immutable instance of [DiscountConfiguration]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): DiscountConfiguration = + DiscountConfiguration(cap, paymentFraction, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -34848,14 +39577,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): AccessSchedule = apply { + fun validate(): DiscountConfiguration = apply { if (validated) { return@apply } - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } + cap().ifPresent { it.validate() } + paymentFraction() validated = true } @@ -34875,18 +39603,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + (cap.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentFraction.asKnown().isPresent) 1 else 0) - class AddScheduleItem + /** Update the discount cap. Set to null to remove an existing cap. */ + class Cap @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val spendTrackerAlias: JsonField, private val additionalProperties: MutableMap, ) { @@ -34895,15 +39620,14 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) + spendTrackerAlias: JsonField = JsonMissing.of(), + ) : this(amount, spendTrackerAlias, mutableMapOf()) /** + * Accumulated spend ceiling above which the discount stops applying. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). @@ -34911,18 +39635,14 @@ private constructor( fun amount(): Double = amount.getRequired("amount") /** + * Alias of the spend tracker this cap is measured against. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun spendTrackerAlias(): String = + spendTrackerAlias.getRequired("spend_tracker_alias") /** * Returns the raw JSON value of [amount]. @@ -34933,24 +39653,14 @@ private constructor( @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [spendTrackerAlias]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an + * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("starting_at") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _spendTrackerAlias(): JsonField = spendTrackerAlias @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -34967,34 +39677,32 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AddScheduleItem]. + * Returns a mutable builder for constructing an instance of [Cap]. * * The following fields are required: * ```java * .amount() - * .endingBefore() - * .startingAt() + * .spendTrackerAlias() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddScheduleItem]. */ + /** A builder for [Cap]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var spendTrackerAlias: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt - additionalProperties = addScheduleItem.additionalProperties.toMutableMap() + internal fun from(cap: Cap) = apply { + amount = cap.amount + spendTrackerAlias = cap.spendTrackerAlias + additionalProperties = cap.additionalProperties.toMutableMap() } + /** Accumulated spend ceiling above which the discount stops applying. */ fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -35006,32 +39714,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) - - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** Alias of the spend tracker this cap is measured against. */ + fun spendTrackerAlias(spendTrackerAlias: String) = + spendTrackerAlias(JsonField.of(spendTrackerAlias)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.spendTrackerAlias] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { + this.spendTrackerAlias = spendTrackerAlias } fun additionalProperties(additionalProperties: Map) = apply { @@ -35057,24 +39752,22 @@ private constructor( } /** - * Returns an immutable instance of [AddScheduleItem]. + * Returns an immutable instance of [Cap]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amount() - * .endingBefore() - * .startingAt() + * .spendTrackerAlias() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddScheduleItem = - AddScheduleItem( + fun build(): Cap = + Cap( checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), + checkRequired("spendTrackerAlias", spendTrackerAlias), additionalProperties.toMutableMap(), ) } @@ -35091,14 +39784,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): AddScheduleItem = apply { + fun validate(): Cap = apply { if (validated) { return@apply } amount() - endingBefore() - startingAt() + spendTrackerAlias() validated = true } @@ -35119,56 +39811,255 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + (if (spendTrackerAlias.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddScheduleItem && + return other is Cap && amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && + spendTrackerAlias == other.spendTrackerAlias && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) + Objects.hash(amount, spendTrackerAlias, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DiscountConfiguration && + cap == other.cap && + paymentFraction == other.paymentFraction && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cap, paymentFraction, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" + } + + class ThresholdBalanceSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of() + ) : this(exclude, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun exclude(): List = exclude.getRequired("exclude") + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exclude") + @ExcludeMissing + fun _exclude(): JsonField> = exclude + + @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 + * [ThresholdBalanceSpecifier]. + * + * The following fields are required: + * ```java + * .exclude() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdBalanceSpecifier]. */ + class Builder internal constructor() { + + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = apply { + exclude = thresholdBalanceSpecifier.exclude.map { it.toMutableList() } + additionalProperties = + thresholdBalanceSpecifier.additionalProperties.toMutableMap() + } + + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + + /** + * Sets [Builder.exclude] to an arbitrary JSON value. + * + * You should usually call [Builder.exclude] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdBalanceSpecifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exclude() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdBalanceSpecifier = + ThresholdBalanceSpecifier( + checkRequired("exclude", exclude).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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ThresholdBalanceSpecifier = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + exclude().forEach { it.validate() } + validated = true } - class RemoveScheduleItem + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Exclude @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, + private val customFieldFilters: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") + fun customFieldFilters(): List = + customFieldFilters.getRequired("custom_field_filters") /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [customFieldFilters]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = customFieldFilters @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -35185,40 +40076,55 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. + * Returns a mutable builder for constructing an instance of [Exclude]. * * The following fields are required: * ```java - * .id() + * .customFieldFilters() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemoveScheduleItem]. */ + /** A builder for [Exclude]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var customFieldFilters: JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id - additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() + internal fun from(exclude: Exclude) = apply { + customFieldFilters = exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun customFieldFilters(customFieldFilters: JsonField>) = + apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -35243,20 +40149,22 @@ private constructor( } /** - * Returns an immutable instance of [RemoveScheduleItem]. + * Returns an immutable instance of [Exclude]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() + * .customFieldFilters() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), + fun build(): Exclude = + Exclude( + checkRequired("customFieldFilters", customFieldFilters).map { + it.toImmutable() + }, additionalProperties.toMutableMap(), ) } @@ -35273,511 +40181,480 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): RemoveScheduleItem = apply { + fun validate(): Exclude = apply { if (validated) { - return@apply - } - - id() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveScheduleItem && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } - - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [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 [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt - - @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 - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() + return@apply + } + + customFieldFilters().forEach { it.validate() } + validated = true } - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() - } + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - fun id(id: String) = id(JsonField.of(id)) + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") + @ExcludeMissing + key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) + fun entity(): Entity = entity.getRequired("entity") /** - * 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. + * @throws MetronomeInvalidDataException if 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(amount: JsonField) = apply { this.amount = amount } + fun key(): String = key.getRequired("key") - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun value(): String = value.getRequired("value") /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Returns the raw JSON value of [entity]. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Unlike [entity], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + @JsonProperty("entity") + @ExcludeMissing + fun _entity(): JsonField = entity - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Returns the raw JSON value of [value]. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { + + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = + customFieldFilter.additionalProperties.toMutableMap() + } + + fun entity(entity: Entity) = entity(JsonField.of(entity)) + + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } + + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + entity().validate() + key() + value() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + companion object { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + @JvmField val COMMIT = of("Commit") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val CONTRACT_CREDIT = of("ContractCredit") - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) - } + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } - override fun hashCode(): Int = hashCode + /** An enum containing [Entity]'s known values. */ + enum class Known { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Entity] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> + throw MetronomeInvalidDataException("Unknown Entity: $value") + } - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } - /** - * If provided, updates the credit to use the specified rate type for current and future - * invoices. Previously finalized invoices will need to be voided and regenerated to reflect - * the rate type change. - */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + known() + validated = true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JvmField val LIST_RATE = of("LIST_RATE") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + return other is Entity && value == other.value + } - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } + override fun hashCode() = value.hashCode() - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } + override fun toString() = value.toString() + } - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST_RATE, - COMMIT_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown value. - */ - _UNKNOWN, - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN - } + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RateType = apply { - if (validated) { - return@apply + return other is Exclude && + customFieldFilters == other.customFieldFilters && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(customFieldFilters, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is RateType && value == other.value + return other is ThresholdBalanceSpecifier && + exclude == other.exclude && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(exclude, additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -35785,36 +40662,28 @@ private constructor( return true } - return other is UpdateCredit && - creditId == other.creditId && - accessSchedule == other.accessSchedule && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - priority == other.priority && - productId == other.productId && - rateType == other.rateType && - rolloverFraction == other.rolloverFraction && + return other is UpdatePrepaidBalanceThresholdConfiguration && + commit == other.commit && + customCreditTypeId == other.customCreditTypeId && + discountConfiguration == other.discountConfiguration && + isEnabled == other.isEnabled && + paymentGateConfig == other.paymentGateConfig && + rechargeToAmount == other.rechargeToAmount && + thresholdAmount == other.thresholdAmount && + thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - creditId, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, additionalProperties, ) } @@ -35822,198 +40691,150 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateCredit{creditId=$creditId, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, additionalProperties=$additionalProperties}" + "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" } - class UpdatePrepaidBalanceThresholdConfiguration + class UpdateRecurringCommit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val commit: JsonField, - private val customCreditTypeId: JsonField, - private val discountConfiguration: JsonField, - private val isEnabled: JsonField, - private val paymentGateConfig: JsonField, - private val rechargeToAmount: JsonField, - private val thresholdAmount: JsonField, - private val thresholdBalanceSpecifiers: JsonField>, + private val recurringCommitId: JsonField, + private val accessAmount: JsonField, + private val endingBefore: JsonField, + private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), - @JsonProperty("custom_credit_type_id") - @ExcludeMissing - customCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("discount_configuration") - @ExcludeMissing - discountConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("is_enabled") - @ExcludeMissing - isEnabled: JsonField = JsonMissing.of(), - @JsonProperty("payment_gate_config") + @JsonProperty("recurring_commit_id") @ExcludeMissing - paymentGateConfig: JsonField = JsonMissing.of(), - @JsonProperty("recharge_to_amount") + recurringCommitId: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") @ExcludeMissing - rechargeToAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_amount") + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") @ExcludeMissing - thresholdAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_balance_specifiers") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("invoice_amount") @ExcludeMissing - thresholdBalanceSpecifiers: JsonField> = - JsonMissing.of(), - ) : this( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + invoiceAmount: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + ) : this( + recurringCommitId, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, mutableMapOf(), ) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun commit(): Optional = commit.getOptional("commit") - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold commit amount - * will be in terms of this credit type instead of the fiat currency. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun customCreditTypeId(): Optional = - customCreditTypeId.getOptional("custom_credit_type_id") + fun recurringCommitId(): String = recurringCommitId.getRequired("recurring_commit_id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun discountConfiguration(): Optional = - discountConfiguration.getOptional("discount_configuration") + fun accessAmount(): Optional = accessAmount.getOptional("access_amount") /** - * When set to false, the contract will not be evaluated against the threshold_amount. - * Toggling to true will result an immediate evaluation, regardless of prior state. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun paymentGateConfig(): Optional = - paymentGateConfig.getOptional("payment_gate_config") + fun invoiceAmount(): Optional = invoiceAmount.getOptional("invoice_amount") /** - * Specify the amount the balance should be recharged to. + * If provided, updates the rounding config on the recurring commit. Set to null to clear + * rounding. Omit to leave unchanged. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun rechargeToAmount(): Optional = - rechargeToAmount.getOptional("recharge_to_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** - * Specify the threshold amount for the contract. Each time the contract's balance lowers to - * this amount, a threshold charge will be initiated. + * If provided, updates the recurring commit to use the specified rate type when generating + * future commits. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun thresholdAmount(): Optional = thresholdAmount.getOptional("threshold_amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun thresholdBalanceSpecifiers(): Optional> = - thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") - - /** - * Returns the raw JSON value of [commit]. - * - * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + fun rateType(): Optional = rateType.getOptional("rate_type") /** - * Returns the raw JSON value of [customCreditTypeId]. + * Returns the raw JSON value of [recurringCommitId]. * - * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [recurringCommitId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("custom_credit_type_id") + @JsonProperty("recurring_commit_id") @ExcludeMissing - fun _customCreditTypeId(): JsonField = customCreditTypeId + fun _recurringCommitId(): JsonField = recurringCommitId /** - * Returns the raw JSON value of [discountConfiguration]. + * Returns the raw JSON value of [accessAmount]. * - * Unlike [discountConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("discount_configuration") + @JsonProperty("access_amount") @ExcludeMissing - fun _discountConfiguration(): JsonField = discountConfiguration - - /** - * Returns the raw JSON value of [isEnabled]. - * - * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField = isEnabled + fun _accessAmount(): JsonField = accessAmount /** - * Returns the raw JSON value of [paymentGateConfig]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an unexpected + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("payment_gate_config") + @JsonProperty("ending_before") @ExcludeMissing - fun _paymentGateConfig(): JsonField = paymentGateConfig + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [rechargeToAmount]. + * Returns the raw JSON value of [invoiceAmount]. * - * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an unexpected + * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("recharge_to_amount") + @JsonProperty("invoice_amount") @ExcludeMissing - fun _rechargeToAmount(): JsonField = rechargeToAmount + fun _invoiceAmount(): JsonField = invoiceAmount /** - * Returns the raw JSON value of [thresholdAmount]. + * Returns the raw JSON value of [prorationRounding]. * - * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an unexpected + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("threshold_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _thresholdAmount(): JsonField = thresholdAmount + fun _prorationRounding(): JsonField = prorationRounding /** - * Returns the raw JSON value of [thresholdBalanceSpecifiers]. + * Returns the raw JSON value of [rateType]. * - * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("threshold_balance_specifiers") - @ExcludeMissing - fun _thresholdBalanceSpecifiers(): JsonField> = - thresholdBalanceSpecifiers + @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -36030,207 +40851,135 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UpdatePrepaidBalanceThresholdConfiguration]. + * Returns a mutable builder for constructing an instance of [UpdateRecurringCommit]. + * + * The following fields are required: + * ```java + * .recurringCommitId() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + /** A builder for [UpdateRecurringCommit]. */ class Builder internal constructor() { - private var commit: JsonField = JsonMissing.of() - private var customCreditTypeId: JsonField = JsonMissing.of() - private var discountConfiguration: JsonField = JsonMissing.of() - private var isEnabled: JsonField = JsonMissing.of() - private var paymentGateConfig: JsonField = JsonMissing.of() - private var rechargeToAmount: JsonField = JsonMissing.of() - private var thresholdAmount: JsonField = JsonMissing.of() - private var thresholdBalanceSpecifiers: - JsonField>? = - null + private var recurringCommitId: JsonField? = null + private var accessAmount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - updatePrepaidBalanceThresholdConfiguration: - UpdatePrepaidBalanceThresholdConfiguration - ) = apply { - commit = updatePrepaidBalanceThresholdConfiguration.commit - customCreditTypeId = updatePrepaidBalanceThresholdConfiguration.customCreditTypeId - discountConfiguration = - updatePrepaidBalanceThresholdConfiguration.discountConfiguration - isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled - paymentGateConfig = updatePrepaidBalanceThresholdConfiguration.paymentGateConfig - rechargeToAmount = updatePrepaidBalanceThresholdConfiguration.rechargeToAmount - thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount - thresholdBalanceSpecifiers = - updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers.map { - it.toMutableList() - } - additionalProperties = - updatePrepaidBalanceThresholdConfiguration.additionalProperties.toMutableMap() + internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { + recurringCommitId = updateRecurringCommit.recurringCommitId + accessAmount = updateRecurringCommit.accessAmount + endingBefore = updateRecurringCommit.endingBefore + invoiceAmount = updateRecurringCommit.invoiceAmount + prorationRounding = updateRecurringCommit.prorationRounding + rateType = updateRecurringCommit.rateType + additionalProperties = updateRecurringCommit.additionalProperties.toMutableMap() } - fun commit(commit: Commit) = commit(JsonField.of(commit)) - - /** - * Sets [Builder.commit] to an arbitrary JSON value. - * - * You should usually call [Builder.commit] with a well-typed [Commit] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun commit(commit: JsonField) = apply { this.commit = commit } - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold commit - * amount will be in terms of this credit type instead of the fiat currency. - */ - fun customCreditTypeId(customCreditTypeId: String?) = - customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) - - /** - * Alias for calling [Builder.customCreditTypeId] with - * `customCreditTypeId.orElse(null)`. - */ - fun customCreditTypeId(customCreditTypeId: Optional) = - customCreditTypeId(customCreditTypeId.getOrNull()) + fun recurringCommitId(recurringCommitId: String) = + recurringCommitId(JsonField.of(recurringCommitId)) /** - * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. + * Sets [Builder.recurringCommitId] to an arbitrary JSON value. * - * You should usually call [Builder.customCreditTypeId] with a well-typed [String] value + * You should usually call [Builder.recurringCommitId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun customCreditTypeId(customCreditTypeId: JsonField) = apply { - this.customCreditTypeId = customCreditTypeId + fun recurringCommitId(recurringCommitId: JsonField) = apply { + this.recurringCommitId = recurringCommitId } - fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = - discountConfiguration(JsonField.ofNullable(discountConfiguration)) - - /** - * Alias for calling [Builder.discountConfiguration] with - * `discountConfiguration.orElse(null)`. - */ - fun discountConfiguration(discountConfiguration: Optional) = - discountConfiguration(discountConfiguration.getOrNull()) - - /** - * Sets [Builder.discountConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.discountConfiguration] with a well-typed - * [DiscountConfiguration] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun discountConfiguration(discountConfiguration: JsonField) = - apply { - this.discountConfiguration = discountConfiguration - } - - /** - * When set to false, the contract will not be evaluated against the threshold_amount. - * Toggling to true will result an immediate evaluation, regardless of prior state. - */ - fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) /** - * Sets [Builder.isEnabled] to an arbitrary JSON value. + * Sets [Builder.accessAmount] to an arbitrary JSON value. * - * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun isEnabled(isEnabled: JsonField) = apply { this.isEnabled = isEnabled } - - fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = - paymentGateConfig(JsonField.of(paymentGateConfig)) - - /** - * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.paymentGateConfig] with a well-typed - * [PaymentGateConfigV2] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun paymentGateConfig(paymentGateConfig: JsonField) = apply { - this.paymentGateConfig = paymentGateConfig + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount } - /** Specify the amount the balance should be recharged to. */ - fun rechargeToAmount(rechargeToAmount: Double) = - rechargeToAmount(JsonField.of(rechargeToAmount)) + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) /** - * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun rechargeToAmount(rechargeToAmount: JsonField) = apply { - this.rechargeToAmount = rechargeToAmount + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - /** - * Specify the threshold amount for the contract. Each time the contract's balance - * lowers to this amount, a threshold charge will be initiated. - */ - fun thresholdAmount(thresholdAmount: Double) = - thresholdAmount(JsonField.of(thresholdAmount)) + fun invoiceAmount(invoiceAmount: InvoiceAmount) = + invoiceAmount(JsonField.of(invoiceAmount)) /** - * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * Sets [Builder.invoiceAmount] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdAmount] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.invoiceAmount] with a well-typed [InvoiceAmount] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun thresholdAmount(thresholdAmount: JsonField) = apply { - this.thresholdAmount = thresholdAmount + fun invoiceAmount(invoiceAmount: JsonField) = apply { + this.invoiceAmount = invoiceAmount } - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: List? - ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) + /** + * If provided, updates the rounding config on the recurring commit. Set to null to + * clear rounding. Omit to leave unchanged. + */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Alias for calling [Builder.thresholdBalanceSpecifiers] with - * `thresholdBalanceSpecifiers.orElse(null)`. + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: Optional> - ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) /** - * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdBalanceSpecifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: JsonField> - ) = apply { - this.thresholdBalanceSpecifiers = - thresholdBalanceSpecifiers.map { it.toMutableList() } + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } /** - * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * If provided, updates the recurring commit to use the specified rate type when + * generating future commits. + */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addThresholdBalanceSpecifier(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = - apply { - thresholdBalanceSpecifiers = - (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("thresholdBalanceSpecifiers", it) - .add(thresholdBalanceSpecifier) - } - } + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -36252,20 +41001,25 @@ private constructor( } /** - * Returns an immutable instance of [UpdatePrepaidBalanceThresholdConfiguration]. + * Returns an immutable instance of [UpdateRecurringCommit]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recurringCommitId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdatePrepaidBalanceThresholdConfiguration = - UpdatePrepaidBalanceThresholdConfiguration( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): UpdateRecurringCommit = + UpdateRecurringCommit( + checkRequired("recurringCommitId", recurringCommitId), + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties.toMutableMap(), ) } @@ -36281,19 +41035,17 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + fun validate(): UpdateRecurringCommit = apply { if (validated) { return@apply } - commit().ifPresent { it.validate() } - customCreditTypeId() - discountConfiguration().ifPresent { it.validate() } - isEnabled() - paymentGateConfig().ifPresent { it.validate() } - rechargeToAmount() - thresholdAmount() - thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + recurringCommitId() + accessAmount().ifPresent { it.validate() } + endingBefore() + invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } validated = true } @@ -36313,200 +41065,60 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (commit.asKnown().getOrNull()?.validity() ?: 0) + - (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + - (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (isEnabled.asKnown().isPresent) 1 else 0) + - (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + - (if (thresholdAmount.asKnown().isPresent) 1 else 0) + - (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + (if (recurringCommitId.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) - class Commit + class AccessAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val description: JsonField, - private val name: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val specifiers: JsonField>, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") + @JsonProperty("quantity") @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("specifiers") + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - mutableMapOf(), - ) - - fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = - UpdateBaseThresholdCommit.builder() - .description(description) - .name(name) - .priority(priority) - .productId(productId) - .build() - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Specify the name of the line item for the threshold charge. If left blank, it will - * default to the commit product name. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The priority of the commit, used to determine drawdown order. Lower priority commits - * are consumed first. Defaults to 100 if not specified. On updates, set to null to - * clear a previously configured priority. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") - - /** - * The commit product that will be used to generate the line item for commit payment. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") - - /** - * Which products the threshold commit applies to. If both applicable_product_ids and - * applicable_product_tags are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") - - /** - * Which tags the threshold commit applies to. If both applicable_product_ids and - * applicable_product_tags are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") - - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to - * target usage by product or product tag, pass those values in the body of - * `specifiers`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun quantity(): Optional = quantity.getOptional("quantity") /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") /** - * Returns the raw JSON value of [productId]. + * Returns the raw JSON value of [quantity]. * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId - - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds - - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [specifiers]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("specifiers") + @JsonProperty("unit_price") @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -36522,214 +41134,240 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Commit]. */ + /** Returns a mutable builder for constructing an instance of [AccessAmount]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Commit]. */ + /** A builder for [AccessAmount]. */ class Builder internal constructor() { - private var description: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var specifiers: JsonField>? = null + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(commit: Commit) = apply { - description = commit.description - name = commit.name - priority = commit.priority - productId = commit.productId - applicableProductIds = commit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = commit.applicableProductTags.map { it.toMutableList() } - specifiers = commit.specifiers.map { it.toMutableList() } - additionalProperties = commit.additionalProperties.toMutableMap() + internal fun from(accessAmount: AccessAmount) = apply { + quantity = accessAmount.quantity + unitPrice = accessAmount.unitPrice + additionalProperties = accessAmount.additionalProperties.toMutableMap() } - fun description(description: String) = description(JsonField.of(description)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.description] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.description] with a well-typed [String] value + * You should usually call [Builder.quantity] with a well-typed [Double] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun description(description: JsonField) = apply { - this.description = description - } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** - * Specify the name of the line item for the threshold charge. If left blank, it - * will default to the commit product name. - */ - fun name(name: String) = name(JsonField.of(name)) + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - /** - * The priority of the commit, used to determine drawdown order. Lower priority - * commits are consumed first. Defaults to 100 if not specified. On updates, set to - * null to clear a previously configured priority. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The commit product that will be used to generate the line item for commit - * payment. - */ - fun productId(productId: String) = productId(JsonField.of(productId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.productId] to an arbitrary JSON value. + * Returns an immutable instance of [AccessAmount]. * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun productId(productId: JsonField) = apply { this.productId = productId } + fun build(): AccessAmount = + AccessAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + quantity() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(quantity, unitPrice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + class InvoiceAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * Which products the threshold commit applies to. If both applicable_product_ids - * and applicable_product_tags are not provided, the commit applies to all products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + fun toBuilder() = Builder().from(this) - /** - * Which tags the threshold commit applies to. If both applicable_product_ids and - * applicable_product_tags are not provided, the commit applies to all products. - */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + companion object { - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + /** Returns a mutable builder for constructing an instance of [InvoiceAmount]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + /** A builder for [InvoiceAmount]. */ + class Builder internal constructor() { - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } - } + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + @JvmSynthetic + internal fun from(invoiceAmount: InvoiceAmount) = apply { + quantity = invoiceAmount.quantity + unitPrice = invoiceAmount.unitPrice + additionalProperties = invoiceAmount.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -36754,21 +41392,12 @@ private constructor( } /** - * Returns an immutable instance of [Commit]. + * Returns an immutable instance of [InvoiceAmount]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Commit = - Commit( - description, - name, - priority, - productId, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): InvoiceAmount = + InvoiceAmount(quantity, unitPrice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -36783,18 +41412,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): Commit = apply { + fun validate(): InvoiceAmount = apply { if (validated) { return@apply } - description() - name() - priority() - productId() - applicableProductIds() - applicableProductTags() - specifiers().ifPresent { it.forEach { it.validate() } } + quantity() + unitPrice() validated = true } @@ -36814,100 +41438,77 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (description.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Commit && - description == other.description && - name == other.name && - priority == other.priority && - productId == other.productId && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - specifiers == other.specifiers && + return other is InvoiceAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - additionalProperties, - ) + Objects.hash(quantity, unitPrice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" + "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class DiscountConfiguration + /** + * If provided, updates the rounding config on the recurring commit. Set to null to clear + * rounding. Omit to leave unchanged. + */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cap: JsonField, - private val paymentFraction: JsonField, + private val access: JsonField, + private val invoice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), - @JsonProperty("payment_fraction") + @JsonProperty("access") @ExcludeMissing - paymentFraction: JsonField = JsonMissing.of(), - ) : this(cap, paymentFraction, mutableMapOf()) + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Update the discount cap. Set to null to remove an existing cap. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun cap(): Optional = cap.getOptional("cap") + fun access(): Optional = access.getOptional("access") /** - * The fraction of the original amount that the customer pays after applying the - * discount. Set to null to remove the discount fraction. For example, 0.85 means the - * customer pays 85% of the original amount (a 15% discount). - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun paymentFraction(): Optional = - paymentFraction.getOptional("payment_fraction") + fun invoice(): Optional = invoice.getOptional("invoice") /** - * Returns the raw JSON value of [cap]. + * Returns the raw JSON value of [access]. * - * Unlike [cap], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access /** - * Returns the raw JSON value of [paymentFraction]. + * Returns the raw JSON value of [invoice]. * - * Unlike [paymentFraction], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("payment_fraction") - @ExcludeMissing - fun _paymentFraction(): JsonField = paymentFraction + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -36924,73 +41525,52 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DiscountConfiguration]. + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DiscountConfiguration]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var cap: JsonField = JsonMissing.of() - private var paymentFraction: JsonField = JsonMissing.of() + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic - internal fun from(discountConfiguration: DiscountConfiguration) = apply { - cap = discountConfiguration.cap - paymentFraction = discountConfiguration.paymentFraction - additionalProperties = discountConfiguration.additionalProperties.toMutableMap() - } - - /** Update the discount cap. Set to null to remove an existing cap. */ - fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - - /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ - fun cap(cap: Optional) = cap(cap.getOrNull()) - - /** - * Sets [Builder.cap] to an arbitrary JSON value. - * - * You should usually call [Builder.cap] with a well-typed [Cap] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cap(cap: JsonField) = apply { this.cap = cap } + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } - /** - * The fraction of the original amount that the customer pays after applying the - * discount. Set to null to remove the discount fraction. For example, 0.85 means - * the customer pays 85% of the original amount (a 15% discount). - */ - fun paymentFraction(paymentFraction: Double?) = - paymentFraction(JsonField.ofNullable(paymentFraction)) + fun access(access: Access?) = access(JsonField.ofNullable(access)) + + /** Alias for calling [Builder.access] with `access.orElse(null)`. */ + fun access(access: Optional) = access(access.getOrNull()) /** - * Alias for [Builder.paymentFraction]. + * Sets [Builder.access] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun paymentFraction(paymentFraction: Double) = - paymentFraction(paymentFraction as Double?) + fun access(access: JsonField) = apply { this.access = access } - /** - * Alias for calling [Builder.paymentFraction] with `paymentFraction.orElse(null)`. - */ - fun paymentFraction(paymentFraction: Optional) = - paymentFraction(paymentFraction.getOrNull()) + fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) + + /** Alias for calling [Builder.invoice] with `invoice.orElse(null)`. */ + fun invoice(invoice: Optional) = invoice(invoice.getOrNull()) /** - * Sets [Builder.paymentFraction] to an arbitrary JSON value. + * Sets [Builder.invoice] to an arbitrary JSON value. * - * You should usually call [Builder.paymentFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun paymentFraction(paymentFraction: JsonField) = apply { - this.paymentFraction = paymentFraction - } + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -37015,12 +41595,12 @@ private constructor( } /** - * Returns an immutable instance of [DiscountConfiguration]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DiscountConfiguration = - DiscountConfiguration(cap, paymentFraction, additionalProperties.toMutableMap()) + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -37035,13 +41615,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): DiscountConfiguration = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - cap().ifPresent { it.validate() } - paymentFraction() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -37061,64 +41641,64 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cap.asKnown().getOrNull()?.validity() ?: 0) + - (if (paymentFraction.asKnown().isPresent) 1 else 0) + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - /** Update the discount cap. Set to null to remove an existing cap. */ - class Cap + class Access @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val amount: JsonField, - private val spendTrackerAlias: JsonField, + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount") + @JsonProperty("decimal_places") @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("spend_tracker_alias") + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") @ExcludeMissing - spendTrackerAlias: JsonField = JsonMissing.of(), - ) : this(amount, spendTrackerAlias, mutableMapOf()) + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Accumulated spend ceiling above which the discount stops applying. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). * * @throws MetronomeInvalidDataException if 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") + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Alias of the spend tracker this cap is measured against. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun spendTrackerAlias(): String = - spendTrackerAlias.getRequired("spend_tracker_alias") + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") /** - * Returns the raw JSON value of [amount]. + * Returns the raw JSON value of [decimalPlaces]. * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces /** - * Returns the raw JSON value of [spendTrackerAlias]. + * Returns the raw JSON value of [roundingMethod]. * - * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field has an + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("spend_tracker_alias") + @JsonProperty("rounding_method") @ExcludeMissing - fun _spendTrackerAlias(): JsonField = spendTrackerAlias + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -37135,389 +41715,379 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Cap]. + * Returns a mutable builder for constructing an instance of [Access]. * * The following fields are required: * ```java - * .amount() - * .spendTrackerAlias() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Cap]. */ + /** A builder for [Access]. */ class Builder internal constructor() { - private var amount: JsonField? = null - private var spendTrackerAlias: JsonField? = null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cap: Cap) = apply { - amount = cap.amount - spendTrackerAlias = cap.spendTrackerAlias - additionalProperties = cap.additionalProperties.toMutableMap() + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() } - /** Accumulated spend ceiling above which the discount stops applying. */ - 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. + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Alias of the spend tracker this cap is measured against. */ - fun spendTrackerAlias(spendTrackerAlias: String) = - spendTrackerAlias(JsonField.of(spendTrackerAlias)) + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.spendTrackerAlias] with a well-typed - * [String] value instead. This method is primarily for setting the field to an + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { - this.spendTrackerAlias = spendTrackerAlias - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) /** - * Returns an immutable instance of [Cap]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .spendTrackerAlias() - * ``` + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun build(): Cap = - Cap( - checkRequired("amount", amount), - checkRequired("spendTrackerAlias", spendTrackerAlias), - 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 MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Cap = apply { - if (validated) { - return@apply - } - - amount() - spendTrackerAlias() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a 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 (spendTrackerAlias.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } - return other is Cap && - amount == other.amount && - spendTrackerAlias == other.spendTrackerAlias && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, spendTrackerAlias, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DiscountConfiguration && - cap == other.cap && - paymentFraction == other.paymentFraction && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(cap, paymentFraction, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" - } - - class ThresholdBalanceSpecifier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val exclude: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("exclude") - @ExcludeMissing - exclude: JsonField> = JsonMissing.of() - ) : this(exclude, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun exclude(): List = exclude.getRequired("exclude") - - /** - * Returns the raw JSON value of [exclude]. - * - * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("exclude") - @ExcludeMissing - fun _exclude(): JsonField> = exclude - - @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) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [ThresholdBalanceSpecifier]. - * - * The following fields are required: - * ```java - * .exclude() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [ThresholdBalanceSpecifier]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var exclude: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = apply { - exclude = thresholdBalanceSpecifier.exclude.map { it.toMutableList() } - additionalProperties = - thresholdBalanceSpecifier.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) } - fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + private var validated: Boolean = false /** - * Sets [Builder.exclude] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.exclude] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun exclude(exclude: JsonField>) = apply { - this.exclude = exclude.map { it.toMutableList() } + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Adds a single [Exclude] to [Builder.exclude]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Used for best match union deserialization. */ - fun addExclude(exclude: Exclude) = apply { - this.exclude = - (this.exclude ?: JsonField.of(mutableListOf())).also { - checkKnown("exclude", it).add(exclude) + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN } - } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an immutable instance of [ThresholdBalanceSpecifier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .exclude() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ThresholdBalanceSpecifier = - ThresholdBalanceSpecifier( - checkRequired("exclude", exclude).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var validated: Boolean = false + return other is RoundingMethod && value == other.value + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): ThresholdBalanceSpecifier = apply { - if (validated) { - return@apply + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - exclude().forEach { it.validate() } - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - class Exclude + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val customFieldFilters: JsonField>, + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - customFieldFilters: JsonField> = JsonMissing.of() - ) : this(customFieldFilters, mutableMapOf()) + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun customFieldFilters(): List = - customFieldFilters.getRequired("custom_field_filters") + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Returns the raw JSON value of [customFieldFilters]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. * - * Unlike [customFieldFilters], this method doesn't throw if the JSON field has an + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - fun _customFieldFilters(): JsonField> = customFieldFilters + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -37534,54 +42104,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Exclude]. + * Returns a mutable builder for constructing an instance of [Invoice]. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Exclude]. */ + /** A builder for [Invoice]. */ class Builder internal constructor() { - private var customFieldFilters: JsonField>? = - null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(exclude: Exclude) = apply { - customFieldFilters = exclude.customFieldFilters.map { it.toMutableList() } - additionalProperties = exclude.additionalProperties.toMutableMap() + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - fun customFieldFilters(customFieldFilters: List) = - customFieldFilters(JsonField.of(customFieldFilters)) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.customFieldFilters] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun customFieldFilters(customFieldFilters: JsonField>) = - apply { - this.customFieldFilters = customFieldFilters.map { it.toMutableList() } - } + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) /** - * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { - customFieldFilters = - (customFieldFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("customFieldFilters", it).add(customFieldFilter) - } + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = apply { @@ -37607,22 +42185,22 @@ private constructor( } /** - * Returns an immutable instance of [Exclude]. + * Returns an immutable instance of [Invoice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Exclude = - Exclude( - checkRequired("customFieldFilters", customFieldFilters).map { - it.toImmutable() - }, + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -37639,12 +42217,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Exclude = apply { + fun validate(): Invoice = apply { if (validated) { return@apply } - customFieldFilters().forEach { it.validate() } + decimalPlaces() + roundingMethod().validate() validated = true } @@ -37664,201 +42243,113 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class CustomFieldFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val entity: JsonField, - private val key: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("entity") - @ExcludeMissing - entity: JsonField = JsonMissing.of(), - @JsonProperty("key") - @ExcludeMissing - key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(entity, key, value, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun entity(): Entity = entity.getRequired("entity") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun key(): String = key.getRequired("key") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [entity]. - * - * Unlike [entity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("entity") - @ExcludeMissing - fun _entity(): JsonField = entity + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [key]. - * - * Unlike [key], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns the raw JSON value of [value]. + * Returns this class instance's raw value. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @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 - * [CustomFieldFilter]. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomFieldFilter]. */ - class Builder internal constructor() { - - private var entity: JsonField? = null - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(customFieldFilter: CustomFieldFilter) = apply { - entity = customFieldFilter.entity - key = customFieldFilter.key - value = customFieldFilter.value - additionalProperties = - customFieldFilter.additionalProperties.toMutableMap() - } - - fun entity(entity: Entity) = entity(JsonField.of(entity)) - - /** - * Sets [Builder.entity] to an arbitrary JSON value. - * - * You should usually call [Builder.entity] with a well-typed [Entity] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun entity(entity: JsonField) = apply { this.entity = entity } - - fun key(key: String) = key(JsonField.of(key)) - - /** - * Sets [Builder.key] to an arbitrary JSON value. - * - * You should usually call [Builder.key] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun key(key: JsonField) = apply { this.key = key } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val HALF_UP = of("HALF_UP") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val FLOOR = of("FLOOR") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, /** - * Returns an immutable instance of [CustomFieldFilter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. */ - fun build(): CustomFieldFilter = - CustomFieldFilter( - checkRequired("entity", entity), - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -37871,14 +42362,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): CustomFieldFilter = apply { + fun validate(): RoundingMethod = apply { if (validated) { return@apply } - entity().validate() - key() - value() + known() validated = true } @@ -37894,187 +42383,22 @@ private constructor( * Returns a score indicating how many valid values are contained in this object * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (entity.asKnown().getOrNull()?.validity() ?: 0) + - (if (key.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - class Entity - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val COMMIT = of("Commit") - - @JvmField val CONTRACT_CREDIT = of("ContractCredit") - - @JvmField val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") - - @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) - } - - /** An enum containing [Entity]'s known values. */ - enum class Known { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - } - - /** - * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Entity] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - /** - * An enum member indicating that [Entity] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT -> Value.COMMIT - CONTRACT_CREDIT -> Value.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - COMMIT -> Known.COMMIT - CONTRACT_CREDIT -> Known.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT - else -> - throw MetronomeInvalidDataException("Unknown Entity: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Entity = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Entity && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CustomFieldFilter && - entity == other.entity && - key == other.key && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(entity, key, value, additionalProperties) + return other is RoundingMethod && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -38082,19 +42406,20 @@ private constructor( return true } - return other is Exclude && - customFieldFilters == other.customFieldFilters && + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(customFieldFilters, additionalProperties) + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -38102,17 +42427,164 @@ private constructor( return true } - return other is ThresholdBalanceSpecifier && - exclude == other.exclude && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(exclude, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + /** + * If provided, updates the recurring commit to use the specified rate type when generating + * future commits. + */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + LIST_RATE, + COMMIT_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST_RATE, + COMMIT_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -38120,28 +42592,24 @@ private constructor( return true } - return other is UpdatePrepaidBalanceThresholdConfiguration && - commit == other.commit && - customCreditTypeId == other.customCreditTypeId && - discountConfiguration == other.discountConfiguration && - isEnabled == other.isEnabled && - paymentGateConfig == other.paymentGateConfig && - rechargeToAmount == other.rechargeToAmount && - thresholdAmount == other.thresholdAmount && - thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && + return other is UpdateRecurringCommit && + recurringCommitId == other.recurringCommitId && + accessAmount == other.accessAmount && + endingBefore == other.endingBefore && + invoiceAmount == other.invoiceAmount && + prorationRounding == other.prorationRounding && + rateType == other.rateType && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + recurringCommitId, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties, ) } @@ -38149,42 +42617,42 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" + "UpdateRecurringCommit{recurringCommitId=$recurringCommitId, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } - class UpdateRecurringCommit + class UpdateRecurringCredit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val recurringCommitId: JsonField, + private val recurringCreditId: JsonField, private val accessAmount: JsonField, private val endingBefore: JsonField, - private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("recurring_commit_id") + @JsonProperty("recurring_credit_id") @ExcludeMissing - recurringCommitId: JsonField = JsonMissing.of(), + recurringCreditId: JsonField = JsonMissing.of(), @JsonProperty("access_amount") @ExcludeMissing accessAmount: JsonField = JsonMissing.of(), @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - invoiceAmount: JsonField = JsonMissing.of(), + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), ) : this( - recurringCommitId, + recurringCreditId, accessAmount, endingBefore, - invoiceAmount, + prorationRounding, rateType, mutableMapOf(), ) @@ -38193,7 +42661,7 @@ private constructor( * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun recurringCommitId(): String = recurringCommitId.getRequired("recurring_commit_id") + fun recurringCreditId(): String = recurringCreditId.getRequired("recurring_credit_id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -38208,14 +42676,18 @@ private constructor( fun endingBefore(): Optional = endingBefore.getOptional("ending_before") /** + * If provided, updates the rounding config on the recurring credit. Set to null to clear + * rounding. Omit to leave unchanged. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun invoiceAmount(): Optional = invoiceAmount.getOptional("invoice_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** - * If provided, updates the recurring commit to use the specified rate type when generating - * future commits. + * If provided, updates the recurring credit to use the specified rate type when generating + * future credits. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -38223,14 +42695,14 @@ private constructor( fun rateType(): Optional = rateType.getOptional("rate_type") /** - * Returns the raw JSON value of [recurringCommitId]. + * Returns the raw JSON value of [recurringCreditId]. * - * Unlike [recurringCommitId], this method doesn't throw if the JSON field has an unexpected + * Unlike [recurringCreditId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("recurring_commit_id") + @JsonProperty("recurring_credit_id") @ExcludeMissing - fun _recurringCommitId(): JsonField = recurringCommitId + fun _recurringCreditId(): JsonField = recurringCreditId /** * Returns the raw JSON value of [accessAmount]. @@ -38253,14 +42725,14 @@ private constructor( fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [invoiceAmount]. + * Returns the raw JSON value of [prorationRounding]. * - * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an unexpected + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _invoiceAmount(): JsonField = invoiceAmount + fun _prorationRounding(): JsonField = prorationRounding /** * Returns the raw JSON value of [rateType]. @@ -38284,48 +42756,48 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UpdateRecurringCommit]. + * Returns a mutable builder for constructing an instance of [UpdateRecurringCredit]. * * The following fields are required: * ```java - * .recurringCommitId() + * .recurringCreditId() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UpdateRecurringCommit]. */ + /** A builder for [UpdateRecurringCredit]. */ class Builder internal constructor() { - private var recurringCommitId: JsonField? = null + private var recurringCreditId: JsonField? = null private var accessAmount: JsonField = JsonMissing.of() private var endingBefore: JsonField = JsonMissing.of() - private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { - recurringCommitId = updateRecurringCommit.recurringCommitId - accessAmount = updateRecurringCommit.accessAmount - endingBefore = updateRecurringCommit.endingBefore - invoiceAmount = updateRecurringCommit.invoiceAmount - rateType = updateRecurringCommit.rateType - additionalProperties = updateRecurringCommit.additionalProperties.toMutableMap() + internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { + recurringCreditId = updateRecurringCredit.recurringCreditId + accessAmount = updateRecurringCredit.accessAmount + endingBefore = updateRecurringCredit.endingBefore + prorationRounding = updateRecurringCredit.prorationRounding + rateType = updateRecurringCredit.rateType + additionalProperties = updateRecurringCredit.additionalProperties.toMutableMap() } - fun recurringCommitId(recurringCommitId: String) = - recurringCommitId(JsonField.of(recurringCommitId)) + fun recurringCreditId(recurringCreditId: String) = + recurringCreditId(JsonField.of(recurringCreditId)) /** - * Sets [Builder.recurringCommitId] to an arbitrary JSON value. + * Sets [Builder.recurringCreditId] to an arbitrary JSON value. * - * You should usually call [Builder.recurringCommitId] with a well-typed [String] value + * You should usually call [Builder.recurringCreditId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun recurringCommitId(recurringCommitId: JsonField) = apply { - this.recurringCommitId = recurringCommitId + fun recurringCreditId(recurringCreditId: JsonField) = apply { + this.recurringCreditId = recurringCreditId } fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) @@ -38359,23 +42831,33 @@ private constructor( this.endingBefore = endingBefore } - fun invoiceAmount(invoiceAmount: InvoiceAmount) = - invoiceAmount(JsonField.of(invoiceAmount)) + /** + * If provided, updates the rounding config on the recurring credit. Set to null to + * clear rounding. Omit to leave unchanged. + */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Sets [Builder.invoiceAmount] to an arbitrary JSON value. + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceAmount] with a well-typed [InvoiceAmount] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun invoiceAmount(invoiceAmount: JsonField) = apply { - this.invoiceAmount = invoiceAmount + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } /** - * If provided, updates the recurring commit to use the specified rate type when - * generating future commits. + * If provided, updates the recurring credit to use the specified rate type when + * generating future credits. */ fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -38408,23 +42890,23 @@ private constructor( } /** - * Returns an immutable instance of [UpdateRecurringCommit]. + * Returns an immutable instance of [UpdateRecurringCredit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .recurringCommitId() + * .recurringCreditId() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdateRecurringCommit = - UpdateRecurringCommit( - checkRequired("recurringCommitId", recurringCommitId), + fun build(): UpdateRecurringCredit = + UpdateRecurringCredit( + checkRequired("recurringCreditId", recurringCreditId), accessAmount, endingBefore, - invoiceAmount, + prorationRounding, rateType, additionalProperties.toMutableMap(), ) @@ -38441,15 +42923,15 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): UpdateRecurringCommit = apply { + fun validate(): UpdateRecurringCredit = apply { if (validated) { return@apply } - recurringCommitId() + recurringCreditId() accessAmount().ifPresent { it.validate() } endingBefore() - invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } validated = true } @@ -38470,10 +42952,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (recurringCommitId.asKnown().isPresent) 1 else 0) + + (if (recurringCreditId.asKnown().isPresent) 1 else 0) + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + - (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) class AccessAmount @@ -38671,53 +43153,34 @@ private constructor( "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class InvoiceAmount + /** + * If provided, updates the rounding config on the recurring credit. Set to null to clear + * rounding. Omit to leave unchanged. + */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + @JsonProperty("access") @ExcludeMissing access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [access]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -38733,233 +43196,69 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [InvoiceAmount]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceAmount]. */ - class Builder internal constructor() { - - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceAmount: InvoiceAmount) = apply { - quantity = invoiceAmount.quantity - unitPrice = invoiceAmount.unitPrice - additionalProperties = invoiceAmount.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - /** - * Returns an immutable instance of [InvoiceAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of [ProrationRounding]. */ - fun build(): InvoiceAmount = - InvoiceAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): InvoiceAmount = apply { - if (validated) { - return@apply - } - - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InvoiceAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } - - /** - * If provided, updates the recurring commit to use the specified rate type when generating - * future commits. - */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access?) = access(JsonField.ofNullable(access)) + + /** Alias for calling [Builder.access] with `access.orElse(null)`. */ + fun access(access: Optional) = access(access.getOrNull()) - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST_RATE, - COMMIT_RATE, /** - * An enum member indicating that [RateType] was instantiated with an unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -38972,12 +43271,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } validated = true } @@ -38995,523 +43294,414 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UpdateRecurringCommit && - recurringCommitId == other.recurringCommitId && - accessAmount == other.accessAmount && - endingBefore == other.endingBefore && - invoiceAmount == other.invoiceAmount && - rateType == other.rateType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - recurringCommitId, - accessAmount, - endingBefore, - invoiceAmount, - rateType, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UpdateRecurringCommit{recurringCommitId=$recurringCommitId, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, rateType=$rateType, additionalProperties=$additionalProperties}" - } - - class UpdateRecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val recurringCreditId: JsonField, - private val accessAmount: JsonField, - private val endingBefore: JsonField, - private val rateType: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("recurring_credit_id") - @ExcludeMissing - recurringCreditId: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - ) : this(recurringCreditId, accessAmount, endingBefore, rateType, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recurringCreditId(): String = recurringCreditId.getRequired("recurring_credit_id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accessAmount(): Optional = accessAmount.getOptional("access_amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - - /** - * If provided, updates the recurring credit to use the specified rate type when generating - * future credits. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") - - /** - * Returns the raw JSON value of [recurringCreditId]. - * - * Unlike [recurringCreditId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("recurring_credit_id") - @ExcludeMissing - fun _recurringCreditId(): JsonField = recurringCreditId - - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount - - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rate_type") @ExcludeMissing fun _rateType(): JsonField = rateType + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - fun toBuilder() = Builder().from(this) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") - companion object { + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Returns a mutable builder for constructing an instance of [UpdateRecurringCredit]. - * - * The following fields are required: - * ```java - * .recurringCreditId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** A builder for [UpdateRecurringCredit]. */ - class Builder internal constructor() { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var recurringCreditId: JsonField? = null - private var accessAmount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmSynthetic - internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { - recurringCreditId = updateRecurringCredit.recurringCreditId - accessAmount = updateRecurringCredit.accessAmount - endingBefore = updateRecurringCredit.endingBefore - rateType = updateRecurringCredit.rateType - additionalProperties = updateRecurringCredit.additionalProperties.toMutableMap() - } + fun toBuilder() = Builder().from(this) - fun recurringCreditId(recurringCreditId: String) = - recurringCreditId(JsonField.of(recurringCreditId)) + companion object { - /** - * Sets [Builder.recurringCreditId] to an arbitrary JSON value. - * - * You should usually call [Builder.recurringCreditId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun recurringCreditId(recurringCreditId: JsonField) = apply { - this.recurringCreditId = recurringCreditId - } + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun accessAmount(accessAmount: AccessAmount) = accessAmount(JsonField.of(accessAmount)) + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun endingBefore(endingBefore: OffsetDateTime?) = - endingBefore(JsonField.ofNullable(endingBefore)) + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ - fun endingBefore(endingBefore: Optional) = - endingBefore(endingBefore.getOrNull()) + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - /** - * If provided, updates the recurring credit to use the specified rate type when - * generating future credits. - */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns an immutable instance of [UpdateRecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recurringCreditId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateRecurringCredit = - UpdateRecurringCredit( - checkRequired("recurringCreditId", recurringCreditId), - accessAmount, - endingBefore, - rateType, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - private var validated: Boolean = false + private var validated: Boolean = false - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): UpdateRecurringCredit = apply { - if (validated) { - return@apply - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - recurringCreditId() - accessAmount().ifPresent { it.validate() } - endingBefore() - rateType().ifPresent { it.validate() } - validated = true - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (recurringCreditId.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + @JvmField val HALF_UP = of("HALF_UP") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + @JvmField val FLOOR = of("FLOOR") - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + @JvmField val CEILING = of("CEILING") - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - fun toBuilder() = Builder().from(this) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - companion object { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** Returns a mutable builder for constructing an instance of [AccessAmount]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - quantity = accessAmount.quantity - unitPrice = accessAmount.unitPrice - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } + known() + validated = true + } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + return other is RoundingMethod && value == other.value + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode() = value.hashCode() - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun toString() = value.toString() } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessAmount = - AccessAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply - } + override fun hashCode(): Int = hashCode - quantity() - unitPrice() - validated = true + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && + return other is ProrationRounding && + access == other.access && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } /** @@ -39667,6 +43857,7 @@ private constructor( recurringCreditId == other.recurringCreditId && accessAmount == other.accessAmount && endingBefore == other.endingBefore && + prorationRounding == other.prorationRounding && rateType == other.rateType && additionalProperties == other.additionalProperties } @@ -39676,6 +43867,7 @@ private constructor( recurringCreditId, accessAmount, endingBefore, + prorationRounding, rateType, additionalProperties, ) @@ -39684,7 +43876,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateRecurringCredit{recurringCreditId=$recurringCreditId, accessAmount=$accessAmount, endingBefore=$endingBefore, rateType=$rateType, additionalProperties=$additionalProperties}" + "UpdateRecurringCredit{recurringCreditId=$recurringCreditId, accessAmount=$accessAmount, endingBefore=$endingBefore, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } class UpdateScheduledCharge @@ -41865,6 +46057,7 @@ private constructor( private constructor( private val subscriptionId: JsonField, private val endingBefore: JsonField, + private val prorationRounding: JsonField, private val quantityManagementModeUpdate: JsonField, private val quantityUpdates: JsonField>, private val seatUpdates: JsonField, @@ -41879,6 +46072,9 @@ private constructor( @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("quantity_management_mode_update") @ExcludeMissing quantityManagementModeUpdate: JsonField = @@ -41892,6 +46088,7 @@ private constructor( ) : this( subscriptionId, endingBefore, + prorationRounding, quantityManagementModeUpdate, quantityUpdates, seatUpdates, @@ -41908,7 +46105,14 @@ private constructor( * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** * Update the subscription's quantity management mode from QUANTITY_ONLY to SEAT_BASED with @@ -41957,6 +46161,16 @@ private constructor( @ExcludeMissing fun _endingBefore(): JsonField = endingBefore + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [quantityManagementModeUpdate]. * @@ -42017,6 +46231,7 @@ private constructor( private var subscriptionId: JsonField? = null private var endingBefore: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var quantityManagementModeUpdate: JsonField = JsonMissing.of() private var quantityUpdates: JsonField>? = null @@ -42027,6 +46242,7 @@ private constructor( internal fun from(updateSubscription: UpdateSubscription) = apply { subscriptionId = updateSubscription.subscriptionId endingBefore = updateSubscription.endingBefore + prorationRounding = updateSubscription.prorationRounding quantityManagementModeUpdate = updateSubscription.quantityManagementModeUpdate quantityUpdates = updateSubscription.quantityUpdates.map { it.toMutableList() } seatUpdates = updateSubscription.seatUpdates @@ -42065,6 +46281,26 @@ private constructor( this.endingBefore = endingBefore } + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * Update the subscription's quantity management mode from QUANTITY_ONLY to SEAT_BASED * with the provided seat_group_key. @@ -42093,128 +46329,516 @@ private constructor( quantityUpdates(JsonField.of(quantityUpdates)) /** - * Sets [Builder.quantityUpdates] to an arbitrary JSON value. + * Sets [Builder.quantityUpdates] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityUpdates] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun quantityUpdates(quantityUpdates: JsonField>) = apply { + this.quantityUpdates = quantityUpdates.map { it.toMutableList() } + } + + /** + * Adds a single [QuantityUpdate] to [quantityUpdates]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addQuantityUpdate(quantityUpdate: QuantityUpdate) = apply { + quantityUpdates = + (quantityUpdates ?: JsonField.of(mutableListOf())).also { + checkKnown("quantityUpdates", it).add(quantityUpdate) + } + } + + fun seatUpdates(seatUpdates: SeatUpdates) = seatUpdates(JsonField.of(seatUpdates)) + + /** + * Sets [Builder.seatUpdates] to an arbitrary JSON value. + * + * You should usually call [Builder.seatUpdates] with a well-typed [SeatUpdates] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seatUpdates(seatUpdates: JsonField) = apply { + this.seatUpdates = seatUpdates + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateSubscription]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateSubscription = + UpdateSubscription( + checkRequired("subscriptionId", subscriptionId), + endingBefore, + prorationRounding, + quantityManagementModeUpdate, + (quantityUpdates ?: JsonMissing.of()).map { it.toImmutable() }, + seatUpdates, + 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 MetronomeInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UpdateSubscription = apply { + if (validated) { + return@apply + } + + subscriptionId() + endingBefore() + prorationRounding().ifPresent { it.validate() } + quantityManagementModeUpdate().ifPresent { it.validate() } + quantityUpdates().ifPresent { it.forEach { it.validate() } } + seatUpdates().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (quantityManagementModeUpdate.asKnown().getOrNull()?.validity() ?: 0) + + (quantityUpdates.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (seatUpdates.asKnown().getOrNull()?.validity() ?: 0) + + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest 100 + * in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun roundingMethod(): RoundingMethod = roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [ProrationRounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + decimalPlaces = prorationRounding.decimalPlaces + roundingMethod = prorationRounding.roundingMethod + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to nearest + * 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProrationRounding = + ProrationRounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.quantityUpdates] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun quantityUpdates(quantityUpdates: JsonField>) = apply { - this.quantityUpdates = quantityUpdates.map { it.toMutableList() } + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Adds a single [QuantityUpdate] to [quantityUpdates]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Used for best match union deserialization. */ - fun addQuantityUpdate(quantityUpdate: QuantityUpdate) = apply { - quantityUpdates = - (quantityUpdates ?: JsonField.of(mutableListOf())).also { - checkKnown("quantityUpdates", it).add(quantityUpdate) + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN } - } - fun seatUpdates(seatUpdates: SeatUpdates) = seatUpdates(JsonField.of(seatUpdates)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException("Unknown RoundingMethod: $value") + } - /** - * Sets [Builder.seatUpdates] to an arbitrary JSON value. - * - * You should usually call [Builder.seatUpdates] with a well-typed [SeatUpdates] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun seatUpdates(seatUpdates: JsonField) = apply { - this.seatUpdates = seatUpdates - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + known() + validated = true + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an immutable instance of [UpdateSubscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateSubscription = - UpdateSubscription( - checkRequired("subscriptionId", subscriptionId), - endingBefore, - quantityManagementModeUpdate, - (quantityUpdates ?: JsonMissing.of()).map { it.toImmutable() }, - seatUpdates, - additionalProperties.toMutableMap(), - ) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var validated: Boolean = false + return other is RoundingMethod && value == other.value + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): UpdateSubscription = apply { - if (validated) { - return@apply + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - subscriptionId() - endingBefore() - quantityManagementModeUpdate().ifPresent { it.validate() } - quantityUpdates().ifPresent { it.forEach { it.validate() } } - seatUpdates().ifPresent { it.validate() } - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + return other is ProrationRounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (subscriptionId.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (quantityManagementModeUpdate.asKnown().getOrNull()?.validity() ?: 0) + - (quantityUpdates.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (seatUpdates.asKnown().getOrNull()?.validity() ?: 0) + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } /** * Update the subscription's quantity management mode from QUANTITY_ONLY to SEAT_BASED with @@ -44387,6 +49011,7 @@ private constructor( return other is UpdateSubscription && subscriptionId == other.subscriptionId && endingBefore == other.endingBefore && + prorationRounding == other.prorationRounding && quantityManagementModeUpdate == other.quantityManagementModeUpdate && quantityUpdates == other.quantityUpdates && seatUpdates == other.seatUpdates && @@ -44397,6 +49022,7 @@ private constructor( Objects.hash( subscriptionId, endingBefore, + prorationRounding, quantityManagementModeUpdate, quantityUpdates, seatUpdates, @@ -44407,7 +49033,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateSubscription{subscriptionId=$subscriptionId, endingBefore=$endingBefore, quantityManagementModeUpdate=$quantityManagementModeUpdate, quantityUpdates=$quantityUpdates, seatUpdates=$seatUpdates, additionalProperties=$additionalProperties}" + "UpdateSubscription{subscriptionId=$subscriptionId, endingBefore=$endingBefore, prorationRounding=$prorationRounding, quantityManagementModeUpdate=$quantityManagementModeUpdate, quantityUpdates=$quantityUpdates, seatUpdates=$seatUpdates, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponse.kt index 05107970..d44ecb9a 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponse.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponse.kt @@ -6340,6 +6340,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -6352,6 +6353,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -6375,6 +6379,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -6385,6 +6390,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -6432,6 +6444,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -6527,6 +6549,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -6541,6 +6564,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -6553,6 +6578,35 @@ private constructor( overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = + apply { + this.anyCommitOrCreditIds = + anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -6723,6 +6777,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -6751,6 +6806,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -6777,7 +6833,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -7199,6 +7256,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -7211,6 +7269,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -7225,7 +7284,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } class OverwriteRate @@ -8797,6 +8856,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -8856,6 +8916,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -8887,6 +8950,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -9038,6 +9102,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - * The commits will be created on the usage invoice frequency. If provided: - The @@ -9248,6 +9321,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -9342,6 +9425,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() @@ -9371,6 +9455,7 @@ private constructor( name = addRecurringCommit.name netsuiteSalesOrderId = addRecurringCommit.netsuiteSalesOrderId proration = addRecurringCommit.proration + prorationRounding = addRecurringCommit.prorationRounding recurrenceFrequency = addRecurringCommit.recurrenceFrequency rolloverFraction = addRecurringCommit.rolloverFraction specifiers = addRecurringCommit.specifiers.map { it.toMutableList() } @@ -9646,6 +9731,28 @@ private constructor( this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not * provided: - The commits will be created on the usage invoice frequency. If @@ -9792,6 +9899,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -9834,6 +9942,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -9874,6 +9983,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -11461,123 +11571,147 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an + * unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JsonProperty("access") + @ExcludeMissing + fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated - * with an unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -11590,12 +11724,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -11614,27 +11749,4218 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RecurrenceFrequency && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddRecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + contract == other.contract && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAt, + applicableProductIds, + applicableProductTags, + contract, + description, + endingBefore, + hierarchyConfiguration, + invoiceAmount, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddRecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } + + class AddRecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val product: JsonField, + private val rateType: JsonField, + private val startingAt: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val contract: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") + @ExcludeMissing + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("contract") + @ExcludeMissing + contract: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = + JsonMissing.of(), + ) : this( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAt, + applicableProductIds, + applicableProductTags, + contract, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + + /** + * The amount of time the created commits will be valid for + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun priority(): Double = priority.getRequired("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun product(): Product = product.getRequired("product") + + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun rateType(): RateType = rateType.getRequired("rate_type") + + /** + * Determines the start time for the first commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun contract(): Optional = contract.getOptional("contract") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Determines when the contract will stop creating recurring commits. Optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") + + /** + * Optional configuration for recurring credit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") + + /** + * Displayed on invoices. Will be passed through to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + + /** + * Determines whether the first and last commit will be prorated. If not provided, + * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") + + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be + * between 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") + + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount + + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") + @ExcludeMissing + fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product") + @ExcludeMissing + fun _product(): JsonField = product + + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags + + /** + * Returns the raw JSON value of [contract]. + * + * Unlike [contract], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("contract") + @ExcludeMissing + fun _contract(): JsonField = contract + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration + + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency + + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = + subscriptionConfig + + @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 + * [AddRecurringCredit]. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddRecurringCredit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var product: JsonField? = null + private var rateType: JsonField? = null + private var startingAt: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var contract: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = + JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addRecurringCredit: AddRecurringCredit) = apply { + id = addRecurringCredit.id + accessAmount = addRecurringCredit.accessAmount + commitDuration = addRecurringCredit.commitDuration + priority = addRecurringCredit.priority + product = addRecurringCredit.product + rateType = addRecurringCredit.rateType + startingAt = addRecurringCredit.startingAt + applicableProductIds = + addRecurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addRecurringCredit.applicableProductTags.map { it.toMutableList() } + contract = addRecurringCredit.contract + description = addRecurringCredit.description + endingBefore = addRecurringCredit.endingBefore + hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration + name = addRecurringCredit.name + netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId + proration = addRecurringCredit.proration + prorationRounding = addRecurringCredit.prorationRounding + recurrenceFrequency = addRecurringCredit.recurrenceFrequency + rolloverFraction = addRecurringCredit.rolloverFraction + specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = addRecurringCredit.subscriptionConfig + additionalProperties = + addRecurringCredit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = + accessAmount(JsonField.of(accessAmount)) + + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed + * [AccessAmount] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } + + /** The amount of time the created commits will be valid for */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) + + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed + * [CommitDuration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } + + /** Will be passed down to the individual commits */ + fun priority(priority: Double) = priority(JsonField.of(priority)) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + fun product(product: Product) = product(JsonField.of(product)) + + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun product(product: JsonField) = apply { this.product = product } + + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + /** Determines the start time for the first commit */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = + apply { + this.applicableProductIds = + applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = + apply { + this.applicableProductTags = + applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + fun contract(contract: Contract) = contract(JsonField.of(contract)) + + /** + * Sets [Builder.contract] to an arbitrary JSON value. + * + * You should usually call [Builder.contract] with a well-typed [Contract] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun contract(contract: JsonField) = apply { this.contract = contract } + + /** Will be passed down to the individual commits */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Determines when the contract will stop creating recurring commits. Optional + */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + /** Optional configuration for recurring credit hierarchy access control */ + fun hierarchyConfiguration( + hierarchyConfiguration: CommitHierarchyConfiguration + ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + + /** Displayed on invoices. Will be passed through to the individual commits */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Will be passed down to the individual commits */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** + * Determines whether the first and last commit will be prorated. If not + * provided, the default is FIRST_AND_LAST (i.e. prorate both the first and last + * commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) + + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun proration(proration: JsonField) = apply { + this.proration = proration + } + + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + + /** + * The frequency at which the recurring commits will be created. If not + * provided: - The commits will be created on the usage invoice frequency. If + * provided: - The period defined in the duration will correspond to this + * frequency. - Commits will be created aligned with the recurring commit's + * starting_at rather than the usage invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) + + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = + apply { + this.recurrenceFrequency = recurrenceFrequency + } + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be + * between 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } + + /** + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at least + * one of the specifiers to contribute to a commit's or credit's drawdown. + */ + fun specifiers(specifiers: List) = + specifiers(JsonField.of(specifiers)) + + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifier] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifier) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: RecurringCommitSubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [RecurringCommitSubscriptionConfig] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun subscriptionConfig( + subscriptionConfig: JsonField + ) = apply { this.subscriptionConfig = subscriptionConfig } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AddRecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddRecurringCredit = + AddRecurringCredit( + checkRequired("id", id), + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("product", product), + checkRequired("rateType", rateType), + checkRequired("startingAt", startingAt), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + contract, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddRecurringCredit = apply { + if (validated) { + return@apply + } + + id() + accessAmount().validate() + commitDuration().validate() + priority() + product().validate() + rateType().validate() + startingAt() + applicableProductIds() + applicableProductTags() + contract().ifPresent { it.validate() } + description() + endingBefore() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (contract.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + + @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 [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun creditTypeId(creditTypeId: String) = + creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + creditTypeId() + unitPrice() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + /** The amount of time the created commits will be valid for */ + class CommitDuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val unit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("unit") + @ExcludeMissing + unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun value(): Double = value.getRequired("value") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @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 + * [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = + commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } + + value() + unit().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + class Unit + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERIODS = of("PERIODS") + + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } + + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS + } + + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(value, unit, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } + + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Product]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Product = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + /** Whether the created commits will use the commit rate or list rate */ + class RateType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Contract + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Contract]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Contract]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(contract: Contract) = apply { + id = contract.id + additionalProperties = contract.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Contract]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Contract = + Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Contract = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Contract && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Contract{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, + * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access") + @ExcludeMissing + fun _access(): JsonField = access + + @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 + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply + } + + access().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddRecurringCommit && + return other is AddRecurringCredit && id == other.id && accessAmount == other.accessAmount && commitDuration == other.commitDuration && @@ -11648,10 +15974,10 @@ private constructor( description == other.description && endingBefore == other.endingBefore && hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -11674,10 +16000,10 @@ private constructor( description, endingBefore, hierarchyConfiguration, - invoiceAmount, name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -11689,118 +16015,83 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddRecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "AddRecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } - class AddRecurringCredit + class AddResellerRoyalty @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val product: JsonField, - private val rateType: JsonField, - private val startingAt: JsonField, + private val resellerType: JsonField, private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val contract: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val hierarchyConfiguration: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val proration: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, + private val applicableProductTags: JsonField>, + private val awsAccountNumber: JsonField, + private val awsOfferId: JsonField, + private val awsPayerReferenceId: JsonField, + private val endingBefore: JsonField, + private val fraction: JsonField, + private val gcpAccountId: JsonField, + private val gcpOfferId: JsonField, + private val netsuiteResellerId: JsonField, + private val resellerContractValue: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + @JsonProperty("reseller_type") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), + resellerType: JsonField = JsonMissing.of(), @JsonProperty("applicable_product_ids") @ExcludeMissing applicableProductIds: JsonField> = JsonMissing.of(), @JsonProperty("applicable_product_tags") @ExcludeMissing applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("contract") + @JsonProperty("aws_account_number") @ExcludeMissing - contract: JsonField = JsonMissing.of(), - @JsonProperty("description") + awsAccountNumber: JsonField = JsonMissing.of(), + @JsonProperty("aws_offer_id") @ExcludeMissing - description: JsonField = JsonMissing.of(), + awsOfferId: JsonField = JsonMissing.of(), + @JsonProperty("aws_payer_reference_id") + @ExcludeMissing + awsPayerReferenceId: JsonField = JsonMissing.of(), @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") + @JsonProperty("fraction") @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("proration") + fraction: JsonField = JsonMissing.of(), + @JsonProperty("gcp_account_id") @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") + gcpAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gcp_offer_id") @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") + gcpOfferId: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_reseller_id") @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") + netsuiteResellerId: JsonField = JsonMissing.of(), + @JsonProperty("reseller_contract_value") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") + resellerContractValue: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - subscriptionConfig: JsonField = - JsonMissing.of(), + startingAt: JsonField = JsonMissing.of(), ) : this( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAt, + resellerType, applicableProductIds, applicableProductTags, - contract, - description, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, mutableMapOf(), ) @@ -11809,63 +16100,9 @@ private constructor( * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") - - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") - - /** - * The amount of time the created commits will be valid for - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") - - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun priority(): Double = priority.getRequired("priority") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun product(): Product = product.getRequired("product") - - /** - * Whether the created commits will use the commit rate or list rate - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun rateType(): RateType = rateType.getRequired("rate_type") - - /** - * Determines the start time for the first commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") /** - * Will be passed down to the individual commits - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -11873,8 +16110,6 @@ private constructor( applicableProductIds.getOptional("applicable_product_ids") /** - * Will be passed down to the individual commits - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -11885,170 +16120,76 @@ private constructor( * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun contract(): Optional = contract.getOptional("contract") - - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Determines when the contract will stop creating recurring commits. Optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * Optional configuration for recurring credit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") - - /** - * Displayed on invoices. Will be passed through to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - - /** - * Determines whether the first and last commit will be prorated. If not provided, - * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun proration(): Optional = proration.getOptional("proration") + fun awsAccountNumber(): Optional = + awsAccountNumber.getOptional("aws_account_number") /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be - * between 0 and 1. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + fun awsPayerReferenceId(): Optional = + awsPayerReferenceId.getOptional("aws_payer_reference_id") /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** - * Attach a subscription to the recurring commit/credit. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun fraction(): Optional = fraction.getOptional("fraction") - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an - * unexpected type. + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount + fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("priority") - @ExcludeMissing - fun _priority(): JsonField = priority + fun netsuiteResellerId(): Optional = + netsuiteResellerId.getOptional("netsuite_reseller_id") /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("product") - @ExcludeMissing - fun _product(): JsonField = product + fun resellerContractValue(): Optional = + resellerContractValue.getOptional("reseller_contract_value") /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + fun startingAt(): Optional = startingAt.getOptional("starting_at") /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [resellerType]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an + * Unlike [resellerType], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("starting_at") + @JsonProperty("reseller_type") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _resellerType(): JsonField = resellerType /** * Returns the raw JSON value of [applicableProductIds]. @@ -12071,295 +16212,184 @@ private constructor( fun _applicableProductTags(): JsonField> = applicableProductTags /** - * Returns the raw JSON value of [contract]. - * - * Unlike [contract], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("contract") - @ExcludeMissing - fun _contract(): JsonField = contract - - /** - * Returns the raw JSON value of [description]. + * Returns the raw JSON value of [awsAccountNumber]. * - * Unlike [description], this method doesn't throw if the JSON field has an + * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("description") + @JsonProperty("aws_account_number") @ExcludeMissing - fun _description(): JsonField = description + fun _awsAccountNumber(): JsonField = awsAccountNumber /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [awsOfferId]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * Unlike [awsOfferId], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("ending_before") + @JsonProperty("aws_offer_id") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _awsOfferId(): JsonField = awsOfferId /** - * Returns the raw JSON value of [hierarchyConfiguration]. + * Returns the raw JSON value of [awsPayerReferenceId]. * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("hierarchy_configuration") + @JsonProperty("aws_payer_reference_id") @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("netsuite_sales_order_id") + @JsonProperty("ending_before") @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [proration]. + * Returns the raw JSON value of [fraction]. * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration - - /** - * Returns the raw JSON value of [recurrenceFrequency]. - * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recurrence_frequency") + @JsonProperty("fraction") @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + fun _fraction(): JsonField = fraction /** - * Returns the raw JSON value of [rolloverFraction]. + * Returns the raw JSON value of [gcpAccountId]. * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("rollover_fraction") + @JsonProperty("gcp_account_id") @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + fun _gcpAccountId(): JsonField = gcpAccountId /** - * Returns the raw JSON value of [specifiers]. + * Returns the raw JSON value of [gcpOfferId]. * - * Unlike [specifiers], this method doesn't throw if the JSON field has an + * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("specifiers") + @JsonProperty("gcp_offer_id") @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun _gcpOfferId(): JsonField = gcpOfferId /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") - @ExcludeMissing - fun _subscriptionConfig(): JsonField = - subscriptionConfig - - @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 - * [AddRecurringCredit]. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddRecurringCredit]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var product: JsonField? = null - private var rateType: JsonField? = null - private var startingAt: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var contract: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = - JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addRecurringCredit: AddRecurringCredit) = apply { - id = addRecurringCredit.id - accessAmount = addRecurringCredit.accessAmount - commitDuration = addRecurringCredit.commitDuration - priority = addRecurringCredit.priority - product = addRecurringCredit.product - rateType = addRecurringCredit.rateType - startingAt = addRecurringCredit.startingAt - applicableProductIds = - addRecurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addRecurringCredit.applicableProductTags.map { it.toMutableList() } - contract = addRecurringCredit.contract - description = addRecurringCredit.description - endingBefore = addRecurringCredit.endingBefore - hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration - name = addRecurringCredit.name - netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId - proration = addRecurringCredit.proration - recurrenceFrequency = addRecurringCredit.recurrenceFrequency - rolloverFraction = addRecurringCredit.rolloverFraction - specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = addRecurringCredit.subscriptionConfig - additionalProperties = - addRecurringCredit.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = - accessAmount(JsonField.of(accessAmount)) + * Returns the raw JSON value of [netsuiteResellerId]. + * + * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_reseller_id") + @ExcludeMissing + fun _netsuiteResellerId(): JsonField = netsuiteResellerId - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed - * [AccessAmount] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } + /** + * Returns the raw JSON value of [resellerContractValue]. + * + * Unlike [resellerContractValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("reseller_contract_value") + @ExcludeMissing + fun _resellerContractValue(): JsonField = resellerContractValue - /** The amount of time the created commits will be valid for */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.commitDuration] with a well-typed - * [CommitDuration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Will be passed down to the individual commits */ - fun priority(priority: Double) = priority(JsonField.of(priority)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + fun toBuilder() = Builder().from(this) - fun product(product: Product) = product(JsonField.of(product)) + companion object { /** - * Sets [Builder.product] to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of + * [AddResellerRoyalty]. * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * The following fields are required: + * ```java + * .resellerType() + * ``` */ - fun product(product: JsonField) = apply { this.product = product } + @JvmStatic fun builder() = Builder() + } - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** A builder for [AddResellerRoyalty]. */ + class Builder internal constructor() { - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + private var resellerType: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var awsAccountNumber: JsonField = JsonMissing.of() + private var awsOfferId: JsonField = JsonMissing.of() + private var awsPayerReferenceId: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var fraction: JsonField = JsonMissing.of() + private var gcpAccountId: JsonField = JsonMissing.of() + private var gcpOfferId: JsonField = JsonMissing.of() + private var netsuiteResellerId: JsonField = JsonMissing.of() + private var resellerContractValue: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** Determines the start time for the first commit */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + @JvmSynthetic + internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { + resellerType = addResellerRoyalty.resellerType + applicableProductIds = + addResellerRoyalty.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addResellerRoyalty.applicableProductTags.map { it.toMutableList() } + awsAccountNumber = addResellerRoyalty.awsAccountNumber + awsOfferId = addResellerRoyalty.awsOfferId + awsPayerReferenceId = addResellerRoyalty.awsPayerReferenceId + endingBefore = addResellerRoyalty.endingBefore + fraction = addResellerRoyalty.fraction + gcpAccountId = addResellerRoyalty.gcpAccountId + gcpOfferId = addResellerRoyalty.gcpOfferId + netsuiteResellerId = addResellerRoyalty.netsuiteResellerId + resellerContractValue = addResellerRoyalty.resellerContractValue + startingAt = addResellerRoyalty.startingAt + additionalProperties = + addResellerRoyalty.additionalProperties.toMutableMap() + } + + fun resellerType(resellerType: ResellerType) = + resellerType(JsonField.of(resellerType)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.resellerType] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.resellerType] with a well-typed + * [ResellerType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun resellerType(resellerType: JsonField) = apply { + this.resellerType = resellerType } - /** Will be passed down to the individual commits */ fun applicableProductIds(applicableProductIds: List) = applicableProductIds(JsonField.of(applicableProductIds)) @@ -12388,7 +16418,6 @@ private constructor( } } - /** Will be passed down to the individual commits */ fun applicableProductTags(applicableProductTags: List) = applicableProductTags(JsonField.of(applicableProductTags)) @@ -12417,651 +16446,832 @@ private constructor( } } - fun contract(contract: Contract) = contract(JsonField.of(contract)) + fun awsAccountNumber(awsAccountNumber: String) = + awsAccountNumber(JsonField.of(awsAccountNumber)) /** - * Sets [Builder.contract] to an arbitrary JSON value. + * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. * - * You should usually call [Builder.contract] with a well-typed [Contract] value + * You should usually call [Builder.awsAccountNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun awsAccountNumber(awsAccountNumber: JsonField) = apply { + this.awsAccountNumber = awsAccountNumber + } + + fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) + + /** + * Sets [Builder.awsOfferId] to an arbitrary JSON value. + * + * You should usually call [Builder.awsOfferId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun contract(contract: JsonField) = apply { this.contract = contract } + fun awsOfferId(awsOfferId: JsonField) = apply { + this.awsOfferId = awsOfferId + } + + fun awsPayerReferenceId(awsPayerReferenceId: String) = + awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) + + /** + * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.awsPayerReferenceId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { + this.awsPayerReferenceId = awsPayerReferenceId + } + + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) + + /** + * Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. + */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) + + /** + * Sets [Builder.fraction] to an arbitrary JSON value. + * + * You should usually call [Builder.fraction] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun fraction(fraction: JsonField) = apply { this.fraction = fraction } + + fun gcpAccountId(gcpAccountId: String) = + gcpAccountId(JsonField.of(gcpAccountId)) + + /** + * Sets [Builder.gcpAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gcpAccountId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gcpAccountId(gcpAccountId: JsonField) = apply { + this.gcpAccountId = gcpAccountId + } + + fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) + + /** + * Sets [Builder.gcpOfferId] to an arbitrary JSON value. + * + * You should usually call [Builder.gcpOfferId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gcpOfferId(gcpOfferId: JsonField) = apply { + this.gcpOfferId = gcpOfferId + } + + fun netsuiteResellerId(netsuiteResellerId: String) = + netsuiteResellerId(JsonField.of(netsuiteResellerId)) + + /** + * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteResellerId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { + this.netsuiteResellerId = netsuiteResellerId + } - /** Will be passed down to the individual commits */ - fun description(description: String) = description(JsonField.of(description)) + fun resellerContractValue(resellerContractValue: Double) = + resellerContractValue(JsonField.of(resellerContractValue)) /** - * Sets [Builder.description] to an arbitrary JSON value. + * Sets [Builder.resellerContractValue] to an arbitrary JSON value. * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.resellerContractValue] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun description(description: JsonField) = apply { - this.description = description + fun resellerContractValue(resellerContractValue: JsonField) = apply { + this.resellerContractValue = resellerContractValue } - /** - * Determines when the contract will stop creating recurring commits. Optional - */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed + * You should usually call [Builder.startingAt] with a well-typed * [OffsetDateTime] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } - /** Optional configuration for recurring credit hierarchy access control */ - fun hierarchyConfiguration( - hierarchyConfiguration: CommitHierarchyConfiguration - ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Displayed on invoices. Will be passed through to the individual commits */ - fun name(name: String) = name(JsonField.of(name)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Will be passed down to the individual commits */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Returns an immutable instance of [AddResellerRoyalty]. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .resellerType() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId + fun build(): AddResellerRoyalty = + AddResellerRoyalty( + checkRequired("resellerType", resellerType), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, + endingBefore, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddResellerRoyalty = apply { + if (validated) { + return@apply } - /** - * Determines whether the first and last commit will be prorated. If not - * provided, the default is FIRST_AND_LAST (i.e. prorate both the first and last - * commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + resellerType().validate() + applicableProductIds() + applicableProductTags() + awsAccountNumber() + awsOfferId() + awsPayerReferenceId() + endingBefore() + fraction() + gcpAccountId() + gcpOfferId() + netsuiteResellerId() + resellerContractValue() + startingAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (resellerType.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + + (if (awsOfferId.asKnown().isPresent) 1 else 0) + + (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (fraction.asKnown().isPresent) 1 else 0) + + (if (gcpAccountId.asKnown().isPresent) 1 else 0) + + (if (gcpOfferId.asKnown().isPresent) 1 else 0) + + (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + + (if (resellerContractValue.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + class ResellerType + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.proration] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.proration] with a well-typed [Proration] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. */ - fun proration(proration: JsonField) = apply { - this.proration = proration + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AWS = of("AWS") + + @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") + + @JvmField val GCP = of("GCP") + + @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") + + @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) + } + + /** An enum containing [ResellerType]'s known values. */ + enum class Known { + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, } /** - * The frequency at which the recurring commits will be created. If not - * provided: - The commits will be created on the usage invoice frequency. If - * provided: - The period defined in the duration will correspond to this - * frequency. - Commits will be created aligned with the recurring commit's - * starting_at rather than the usage invoice dates. + * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResellerType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + enum class Value { + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, + /** + * An enum member indicating that [ResellerType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = - apply { - this.recurrenceFrequency = recurrenceFrequency + fun value(): Value = + when (this) { + AWS -> Value.AWS + AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE + GCP -> Value.GCP + GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE + else -> Value._UNKNOWN } /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be - * between 0 and 1. + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + fun known(): Known = + when (this) { + AWS -> Known.AWS + AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE + GCP -> Known.GCP + GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE + else -> + throw MetronomeInvalidDataException("Unknown ResellerType: $value") + } /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at least - * one of the specifiers to contribute to a commit's or credit's drawdown. - */ - fun specifiers(specifiers: List) = - specifiers(JsonField.of(specifiers)) + private var validated: Boolean = false /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } - - /** - * Adds a single [CommitSpecifier] to [specifiers]. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addSpecifier(specifier: CommitSpecifier) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } + fun validate(): ResellerType = apply { + if (validated) { + return@apply + } + + known() + validated = true } - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: RecurringCommitSubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [RecurringCommitSubscriptionConfig] value instead. This method is primarily - * for setting the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun subscriptionConfig( - subscriptionConfig: JsonField - ) = apply { this.subscriptionConfig = subscriptionConfig } + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + return other is ResellerType && value == other.value } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun hashCode() = value.hashCode() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun toString() = value.toString() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns an immutable instance of [AddRecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddRecurringCredit = - AddRecurringCredit( - checkRequired("id", id), - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("product", product), - checkRequired("rateType", rateType), - checkRequired("startingAt", startingAt), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - contract, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, - additionalProperties.toMutableMap(), - ) + return other is AddResellerRoyalty && + resellerType == other.resellerType && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + awsAccountNumber == other.awsAccountNumber && + awsOfferId == other.awsOfferId && + awsPayerReferenceId == other.awsPayerReferenceId && + endingBefore == other.endingBefore && + fraction == other.fraction && + gcpAccountId == other.gcpAccountId && + gcpOfferId == other.gcpOfferId && + netsuiteResellerId == other.netsuiteResellerId && + resellerContractValue == other.resellerContractValue && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties } - private var validated: Boolean = false + private val hashCode: Int by lazy { + Objects.hash( + resellerType, + applicableProductIds, + applicableProductTags, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, + endingBefore, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, endingBefore=$endingBefore, fraction=$fraction, gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } + + class AddScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val product: JsonField, + private val schedule: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + ) : this(id, product, schedule, name, netsuiteSalesOrderId, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun product(): Product = product.getRequired("product") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun schedule(): SchedulePointInTime = schedule.getRequired("schedule") /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * displayed on invoices * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun validate(): AddRecurringCredit = apply { - if (validated) { - return@apply - } + fun name(): Optional = name.getOptional("name") - id() - accessAmount().validate() - commitDuration().validate() - priority() - product().validate() - rateType().validate() - startingAt() - applicableProductIds() - applicableProductTags() - contract().ifPresent { it.validate() } - description() - endingBefore() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - proration().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - validated = true - } + /** + * This field's availability is dependent on your client's configuration. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [product]. * - * Used for best match union deserialization. + * Unlike [product], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (contract.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + @JsonProperty("product") + @ExcludeMissing + fun _product(): JsonField = product - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + companion object { /** - * Returns the raw JSON value of [quantity]. + * Returns a mutable builder for constructing an instance of + * [AddScheduledCharge]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. + * The following fields are required: + * ```java + * .id() + * .product() + * .schedule() + * ``` */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @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 [AccessAmount]. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { - - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } - - fun creditTypeId(creditTypeId: String) = - creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } - - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + /** A builder for [AddScheduledCharge]. */ + class Builder internal constructor() { - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + private var id: JsonField? = null + private var product: JsonField? = null + private var schedule: JsonField? = null + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } + @JvmSynthetic + internal fun from(addScheduledCharge: AddScheduledCharge) = apply { + id = addScheduledCharge.id + product = addScheduledCharge.product + schedule = addScheduledCharge.schedule + name = addScheduledCharge.name + netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId + additionalProperties = + addScheduledCharge.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun id(id: String) = id(JsonField.of(id)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun product(product: Product) = product(JsonField.of(product)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun product(product: JsonField) = apply { this.product = product } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun schedule(schedule: SchedulePointInTime) = schedule(JsonField.of(schedule)) - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [SchedulePointInTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + this.schedule = schedule } - private var validated: Boolean = false + /** displayed on invoices */ + fun name(name: String) = name(JsonField.of(name)) /** - * Validates that the types of all values in this object match their expected - * types recursively. + * Sets [Builder.name] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** This field's availability is dependent on your client's configuration. */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply - } + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - creditTypeId() - unitPrice() - quantity() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AddScheduledCharge]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .product() + * .schedule() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + fun build(): AddScheduledCharge = + AddScheduledCharge( + checkRequired("id", id), + checkRequired("product", product), + checkRequired("schedule", schedule), + name, + netsuiteSalesOrderId, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddScheduledCharge = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) - } + id() + product().validate() + schedule().validate() + name() + netsuiteSalesOrderId() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) - /** The amount of time the created commits will be valid for */ - class CommitDuration + class Product @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val value: JsonField, - private val unit: JsonField, + private val id: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("value") + @JsonProperty("id") @ExcludeMissing - value: JsonField = JsonMissing.of(), - @JsonProperty("unit") + id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) + name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun value(): Double = value.getRequired("value") + fun id(): String = id.getRequired("id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun unit(): Optional = unit.getOptional("unit") + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [id]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * Unlike [id], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [unit]. + * Returns the raw JSON value of [name]. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected + * Unlike [name], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13078,54 +17288,53 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CommitDuration]. + * Returns a mutable builder for constructing an instance of [Product]. * * The following fields are required: * ```java - * .value() + * .id() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CommitDuration]. */ + /** A builder for [Product]. */ class Builder internal constructor() { - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = - commitDuration.additionalProperties.toMutableMap() + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() } - fun value(value: Double) = value(JsonField.of(value)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Double] value + * You should usually call [Builder.id] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun id(id: JsonField) = apply { this.id = id } - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.unit] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.unit] with a well-typed [Unit] value + * You should usually call [Builder.name] with a well-typed [String] value * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun unit(unit: JsonField) = apply { this.unit = unit } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -13150,21 +17359,22 @@ private constructor( } /** - * Returns an immutable instance of [CommitDuration]. + * Returns an immutable instance of [Product]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .value() + * .id() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -13181,13 +17391,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): CommitDuration = apply { + fun validate(): Product = apply { if (validated) { return@apply } - value() - unit().ifPresent { it.validate() } + id() + name() validated = true } @@ -13207,979 +17417,1029 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) - class Unit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash(id, name, additionalProperties) + } - @JvmField val PERIODS = of("PERIODS") + override fun hashCode(): Int = hashCode - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, - /** - * An enum member indicating that [Unit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + return other is AddScheduledCharge && + id == other.id && + product == other.product && + schedule == other.schedule && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + additionalProperties == other.additionalProperties + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN - } + private val hashCode: Int by lazy { + Objects.hash( + id, + product, + schedule, + name, + netsuiteSalesOrderId, + additionalProperties, + ) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } + override fun hashCode(): Int = hashCode - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + override fun toString() = + "AddScheduledCharge{id=$id, product=$product, schedule=$schedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + class AddSubscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingPeriods: JsonField, + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val quantityManagementMode: JsonField, + private val quantitySchedule: JsonField>, + private val startingAt: JsonField, + private val subscriptionRate: JsonField, + private val id: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val fiatCreditTypeId: JsonField, + private val name: JsonField, + private val seatConfig: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("billing_periods") + @ExcludeMissing + billingPeriods: JsonField = JsonMissing.of(), + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("quantity_schedule") + @ExcludeMissing + quantitySchedule: JsonField> = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fiatCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + ) : this( + billingPeriods, + collectionSchedule, + proration, + quantityManagementMode, + quantitySchedule, + startingAt, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + mutableMapOf(), + ) - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } + /** + * Previous, current, and next billing periods for the subscription. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun billingPeriods(): BillingPeriods = billingPeriods.getRequired("billing_periods") - known() - validated = true - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun proration(): Proration = proration.getRequired("proration") - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Determines how the subscription's quantity is controlled. Defaults to + * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly + * on the subscription. `initial_quantity` must be provided with this option. + * Compatible with recurring commits/credits that use POOLED allocation. + * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add + * user_123) to increment and decrement a subscription quantity, rather than + * directly providing the quantity. You must use a **SEAT_BASED** subscription to + * use a linked recurring credit with an allocation per seat. `seat_config` must be + * provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun quantityManagementMode(): QuantityManagementMode = + quantityManagementMode.getRequired("quantity_management_mode") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * List of quantity schedule items for the subscription. Only includes the current + * quantity and future quantity changes. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun quantitySchedule(): List = + quantitySchedule.getRequired("quantity_schedule") - return other is Unit && value == other.value - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - override fun hashCode() = value.hashCode() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun subscriptionRate(): SubscriptionRate = + subscriptionRate.getRequired("subscription_rate") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties - } + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun customFields(): Optional = + customFields.getOptional("custom_fields") - private val hashCode: Int by lazy { - Objects.hash(value, unit, additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - override fun hashCode(): Int = hashCode + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun fiatCreditTypeId(): Optional = + fiatCreditTypeId.getOptional("fiat_credit_type_id") - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns the raw JSON value of [billingPeriods]. + * + * Unlike [billingPeriods], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_periods") + @ExcludeMissing + fun _billingPeriods(): JsonField = billingPeriods - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = + quantityManagementMode - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [quantitySchedule]. + * + * Unlike [quantitySchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_schedule") + @ExcludeMissing + fun _quantitySchedule(): JsonField> = quantitySchedule - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - companion object { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - /** A builder for [Product]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - fun id(id: String) = id(JsonField.of(id)) + /** + * Returns the raw JSON value of [fiatCreditTypeId]. + * + * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of [AddSubscription]. + * + * The following fields are required: + * ```java + * .billingPeriods() + * .collectionSchedule() + * .proration() + * .quantityManagementMode() + * .quantitySchedule() + * .startingAt() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [AddSubscription]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) + private var billingPeriods: JsonField? = null + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var quantityManagementMode: JsonField? = null + private var quantitySchedule: JsonField>? = null + private var startingAt: JsonField? = null + private var subscriptionRate: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var fiatCreditTypeId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addSubscription: AddSubscription) = apply { + billingPeriods = addSubscription.billingPeriods + collectionSchedule = addSubscription.collectionSchedule + proration = addSubscription.proration + quantityManagementMode = addSubscription.quantityManagementMode + quantitySchedule = + addSubscription.quantitySchedule.map { it.toMutableList() } + startingAt = addSubscription.startingAt + subscriptionRate = addSubscription.subscriptionRate + id = addSubscription.id + billingCycleConfig = addSubscription.billingCycleConfig + customFields = addSubscription.customFields + description = addSubscription.description + endingBefore = addSubscription.endingBefore + fiatCreditTypeId = addSubscription.fiatCreditTypeId + name = addSubscription.name + seatConfig = addSubscription.seatConfig + additionalProperties = addSubscription.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** Previous, current, and next billing periods for the subscription. */ + fun billingPeriods(billingPeriods: BillingPeriods) = + billingPeriods(JsonField.of(billingPeriods)) /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Sets [Builder.billingPeriods] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * You should usually call [Builder.billingPeriods] with a well-typed + * [BillingPeriods] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun validate(): Product = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true + fun billingPeriods(billingPeriods: JsonField) = apply { + this.billingPeriods = billingPeriods } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun collectionSchedule(collectionSchedule: JsonField) = + apply { + this.collectionSchedule = collectionSchedule } - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - /** Whether the created commits will use the commit rate or list rate */ - class RateType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun proration(proration: Proration) = proration(JsonField.of(proration)) /** - * Returns this class instance's raw value. + * Sets [Builder.proration] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.proration] with a well-typed [Proration] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } - - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, + fun proration(proration: JsonField) = apply { + this.proration = proration } /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Determines how the subscription's quantity is controlled. Defaults to + * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified + * directly on the subscription. `initial_quantity` must be provided with this + * option. Compatible with recurring commits/credits that use POOLED allocation. + * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add + * user_123) to increment and decrement a subscription quantity, rather than + * directly providing the quantity. You must use a **SEAT_BASED** subscription + * to use a linked recurring credit with an allocation per seat. `seat_config` + * must be provided with this option. */ - enum class Value { - COMMIT_RATE, - LIST_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN - } + fun quantityManagementMode( + quantityManagementMode: JsonField + ) = apply { this.quantityManagementMode = quantityManagementMode } /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. + * List of quantity schedule items for the subscription. Only includes the + * current quantity and future quantity changes. */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + fun quantitySchedule(quantitySchedule: List) = + quantitySchedule(JsonField.of(quantitySchedule)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.quantitySchedule] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * You should usually call [Builder.quantitySchedule] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun quantitySchedule(quantitySchedule: JsonField>) = + apply { + this.quantitySchedule = quantitySchedule.map { it.toMutableList() } } - private var validated: Boolean = false - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Adds a single [QuantitySchedule] to [Builder.quantitySchedule]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun validate(): RateType = apply { - if (validated) { - return@apply - } - - known() - validated = true + fun addQuantitySchedule(quantitySchedule: QuantitySchedule) = apply { + this.quantitySchedule = + (this.quantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("quantitySchedule", it).add(quantitySchedule) + } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Contract - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate + } + + fun id(id: String) = id(JsonField.of(id)) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun id(): String = id.getRequired("id") + fun id(id: JsonField) = apply { this.id = id } + + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) /** - * Returns the raw JSON value of [id]. + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun billingCycleConfig(billingCycleConfig: JsonField) = + apply { + this.billingCycleConfig = billingCycleConfig + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = + customFields(JsonField.of(customFields)) + + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed + * [CustomFields] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun description(description: String) = description(JsonField.of(description)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - companion object { + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns a mutable builder for constructing an instance of [Contract]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - /** A builder for [Contract]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + fun fiatCreditTypeId(fiatCreditTypeId: String) = + fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) - @JvmSynthetic - internal fun from(contract: Contract) = apply { - id = contract.id - additionalProperties = contract.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { + this.fiatCreditTypeId = fiatCreditTypeId + } - fun id(id: String) = id(JsonField.of(id)) + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an immutable instance of [Contract]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Contract = - Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Validates that the types of all values in this object match their expected - * types recursively. + * Returns an immutable instance of [AddSubscription]. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Contract = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The following fields are required: + * ```java + * .billingPeriods() + * .collectionSchedule() + * .proration() + * .quantityManagementMode() + * .quantitySchedule() + * .startingAt() + * .subscriptionRate() + * ``` * - * Used for best match union deserialization. + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + fun build(): AddSubscription = + AddSubscription( + checkRequired("billingPeriods", billingPeriods), + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("quantityManagementMode", quantityManagementMode), + checkRequired("quantitySchedule", quantitySchedule).map { + it.toImmutable() + }, + checkRequired("startingAt", startingAt), + checkRequired("subscriptionRate", subscriptionRate), + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Contract && - id == other.id && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddSubscription = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Contract{id=$id, additionalProperties=$additionalProperties}" + billingPeriods().validate() + collectionSchedule().validate() + proration().validate() + quantityManagementMode().validate() + quantitySchedule().forEach { it.validate() } + startingAt() + subscriptionRate().validate() + id() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + endingBefore() + fiatCreditTypeId() + name() + seatConfig().ifPresent { it.validate() } + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Determines whether the first and last commit will be prorated. If not provided, - * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Proration - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val NONE = of("NONE") - - @JvmField val FIRST = of("FIRST") - - @JvmField val LAST = of("LAST") - - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + @JvmSynthetic + internal fun validity(): Int = + (billingPeriods.asKnown().getOrNull()?.validity() ?: 0) + + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (quantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + /** Previous, current, and next billing periods for the subscription. */ + class BillingPeriods + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val current: JsonField, + private val next: JsonField, + private val previous: JsonField, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + @JsonCreator + private constructor( + @JsonProperty("current") + @ExcludeMissing + current: JsonField = JsonMissing.of(), + @JsonProperty("next") + @ExcludeMissing + next: JsonField = JsonMissing.of(), + @JsonProperty("previous") + @ExcludeMissing + previous: JsonField = JsonMissing.of(), + ) : this(current, next, previous, mutableMapOf()) /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun current(): Optional = current.getOptional("current") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + fun next(): Optional = next.getOptional("next") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + fun previous(): Optional = previous.getOptional("previous") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [current]. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * Unlike [current], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("current") + @ExcludeMissing + fun _current(): JsonField = current /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Returns the raw JSON value of [next]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * Unlike [next], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun validate(): Proration = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonProperty("next") @ExcludeMissing fun _next(): JsonField = next /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [previous]. * - * Used for best match union deserialization. + * Unlike [previous], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("previous") + @ExcludeMissing + fun _previous(): JsonField = previous - return other is Proration && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) companion object { - @JvmField val MONTHLY = of("MONTHLY") + /** + * Returns a mutable builder for constructing an instance of + * [BillingPeriods]. + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val QUARTERLY = of("QUARTERLY") + /** A builder for [BillingPeriods]. */ + class Builder internal constructor() { - @JvmField val ANNUAL = of("ANNUAL") + private var current: JsonField = JsonMissing.of() + private var next: JsonField = JsonMissing.of() + private var previous: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmField val WEEKLY = of("WEEKLY") + @JvmSynthetic + internal fun from(billingPeriods: BillingPeriods) = apply { + current = billingPeriods.current + next = billingPeriods.next + previous = billingPeriods.previous + additionalProperties = + billingPeriods.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) - } + fun current(current: Current) = current(JsonField.of(current)) - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** + * Sets [Builder.current] to an arbitrary JSON value. + * + * You should usually call [Builder.current] with a well-typed [Current] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun current(current: JsonField) = apply { this.current = current } + + fun next(next: Next) = next(JsonField.of(next)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated - * with an unknown value. + * Sets [Builder.next] to an arbitrary JSON value. + * + * You should usually call [Builder.next] with a well-typed [Next] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun next(next: JsonField) = apply { this.next = next } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun previous(previous: Previous) = previous(JsonField.of(previous)) + + /** + * Sets [Builder.previous] to an arbitrary JSON value. + * + * You should usually call [Builder.previous] with a well-typed [Previous] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previous(previous: JsonField) = apply { + this.previous = previous } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [BillingPeriods]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BillingPeriods = + BillingPeriods( + current, + next, + previous, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false /** @@ -14192,1360 +18452,964 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): BillingPeriods = apply { if (validated) { return@apply } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RecurrenceFrequency && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddRecurringCredit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - contract == other.contract && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAt, - applicableProductIds, - applicableProductTags, - contract, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) - } + current().ifPresent { it.validate() } + next().ifPresent { it.validate() } + previous().ifPresent { it.validate() } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "AddRecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (current.asKnown().getOrNull()?.validity() ?: 0) + + (next.asKnown().getOrNull()?.validity() ?: 0) + + (previous.asKnown().getOrNull()?.validity() ?: 0) - class AddResellerRoyalty - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val resellerType: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val awsAccountNumber: JsonField, - private val awsOfferId: JsonField, - private val awsPayerReferenceId: JsonField, - private val endingBefore: JsonField, - private val fraction: JsonField, - private val gcpAccountId: JsonField, - private val gcpOfferId: JsonField, - private val netsuiteResellerId: JsonField, - private val resellerContractValue: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + class Current + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("reseller_type") - @ExcludeMissing - resellerType: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("aws_account_number") - @ExcludeMissing - awsAccountNumber: JsonField = JsonMissing.of(), - @JsonProperty("aws_offer_id") - @ExcludeMissing - awsOfferId: JsonField = JsonMissing.of(), - @JsonProperty("aws_payer_reference_id") - @ExcludeMissing - awsPayerReferenceId: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("fraction") - @ExcludeMissing - fraction: JsonField = JsonMissing.of(), - @JsonProperty("gcp_account_id") - @ExcludeMissing - gcpAccountId: JsonField = JsonMissing.of(), - @JsonProperty("gcp_offer_id") - @ExcludeMissing - gcpOfferId: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_reseller_id") - @ExcludeMissing - netsuiteResellerId: JsonField = JsonMissing.of(), - @JsonProperty("reseller_contract_value") - @ExcludeMissing - resellerContractValue: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this( - resellerType, - applicableProductIds, - applicableProductTags, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - mutableMapOf(), - ) + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun awsAccountNumber(): Optional = - awsAccountNumber.getOptional("aws_account_number") + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun awsPayerReferenceId(): Optional = - awsPayerReferenceId.getOptional("aws_payer_reference_id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun fraction(): Optional = fraction.getOptional("fraction") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") + /** + * Returns a mutable builder for constructing an instance of [Current]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") + /** A builder for [Current]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netsuiteResellerId(): Optional = - netsuiteResellerId.getOptional("netsuite_reseller_id") + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(current: Current) = apply { + endingBefore = current.endingBefore + startingAt = current.startingAt + additionalProperties = current.additionalProperties.toMutableMap() + } + + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun resellerContractValue(): Optional = - resellerContractValue.getOptional("reseller_contract_value") + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Returns the raw JSON value of [resellerType]. - * - * Unlike [resellerType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reseller_type") - @ExcludeMissing - fun _resellerType(): JsonField = resellerType + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [awsAccountNumber]. - * - * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_account_number") - @ExcludeMissing - fun _awsAccountNumber(): JsonField = awsAccountNumber + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [awsOfferId]. - * - * Unlike [awsOfferId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_offer_id") - @ExcludeMissing - fun _awsOfferId(): JsonField = awsOfferId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [awsPayerReferenceId]. - * - * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_payer_reference_id") - @ExcludeMissing - fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId + /** + * Returns an immutable instance of [Current]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Current = + Current( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + private var validated: Boolean = false - /** - * Returns the raw JSON value of [fraction]. - * - * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fraction") - @ExcludeMissing - fun _fraction(): JsonField = fraction + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Current = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [gcpAccountId]. - * - * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gcp_account_id") - @ExcludeMissing - fun _gcpAccountId(): JsonField = gcpAccountId + endingBefore() + startingAt() + validated = true + } - /** - * Returns the raw JSON value of [gcpOfferId]. - * - * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gcp_offer_id") - @ExcludeMissing - fun _gcpOfferId(): JsonField = gcpOfferId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [netsuiteResellerId]. - * - * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_reseller_id") - @ExcludeMissing - fun _netsuiteResellerId(): JsonField = netsuiteResellerId + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [resellerContractValue]. - * - * Unlike [resellerContractValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("reseller_contract_value") - @ExcludeMissing - fun _resellerContractValue(): JsonField = resellerContractValue + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + return other is Current && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode(): Int = hashCode - fun toBuilder() = Builder().from(this) + override fun toString() = + "Current{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } + + class Next + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") - /** - * Returns a mutable builder for constructing an instance of - * [AddResellerRoyalty]. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** A builder for [AddResellerRoyalty]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private var resellerType: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var awsAccountNumber: JsonField = JsonMissing.of() - private var awsOfferId: JsonField = JsonMissing.of() - private var awsPayerReferenceId: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var fraction: JsonField = JsonMissing.of() - private var gcpAccountId: JsonField = JsonMissing.of() - private var gcpOfferId: JsonField = JsonMissing.of() - private var netsuiteResellerId: JsonField = JsonMissing.of() - private var resellerContractValue: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - @JvmSynthetic - internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { - resellerType = addResellerRoyalty.resellerType - applicableProductIds = - addResellerRoyalty.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addResellerRoyalty.applicableProductTags.map { it.toMutableList() } - awsAccountNumber = addResellerRoyalty.awsAccountNumber - awsOfferId = addResellerRoyalty.awsOfferId - awsPayerReferenceId = addResellerRoyalty.awsPayerReferenceId - endingBefore = addResellerRoyalty.endingBefore - fraction = addResellerRoyalty.fraction - gcpAccountId = addResellerRoyalty.gcpAccountId - gcpOfferId = addResellerRoyalty.gcpOfferId - netsuiteResellerId = addResellerRoyalty.netsuiteResellerId - resellerContractValue = addResellerRoyalty.resellerContractValue - startingAt = addResellerRoyalty.startingAt - additionalProperties = - addResellerRoyalty.additionalProperties.toMutableMap() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun resellerType(resellerType: ResellerType) = - resellerType(JsonField.of(resellerType)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.resellerType] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerType] with a well-typed - * [ResellerType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun resellerType(resellerType: JsonField) = apply { - this.resellerType = resellerType - } + fun toBuilder() = Builder().from(this) - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + companion object { - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = - apply { - this.applicableProductIds = - applicableProductIds.map { it.toMutableList() } + /** + * Returns a mutable builder for constructing an instance of [Next]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + /** A builder for [Next]. */ + class Builder internal constructor() { - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = - apply { - this.applicableProductTags = - applicableProductTags.map { it.toMutableList() } - } + @JvmSynthetic + internal fun from(next: Next) = apply { + endingBefore = next.endingBefore + startingAt = next.startingAt + additionalProperties = next.additionalProperties.toMutableMap() + } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - } - fun awsAccountNumber(awsAccountNumber: String) = - awsAccountNumber(JsonField.of(awsAccountNumber)) + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.awsAccountNumber] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun awsAccountNumber(awsAccountNumber: JsonField) = apply { - this.awsAccountNumber = awsAccountNumber - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.awsOfferId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsOfferId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun awsOfferId(awsOfferId: JsonField) = apply { - this.awsOfferId = awsOfferId - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun awsPayerReferenceId(awsPayerReferenceId: String) = - awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsPayerReferenceId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { - this.awsPayerReferenceId = awsPayerReferenceId - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun endingBefore(endingBefore: OffsetDateTime?) = - endingBefore(JsonField.ofNullable(endingBefore)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Next]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Next = + Next( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. - */ - fun endingBefore(endingBefore: Optional) = - endingBefore(endingBefore.getOrNull()) + private var validated: Boolean = false - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Next = apply { + if (validated) { + return@apply + } - fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) + endingBefore() + startingAt() + validated = true + } - /** - * Sets [Builder.fraction] to an arbitrary JSON value. - * - * You should usually call [Builder.fraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun fraction(fraction: JsonField) = apply { this.fraction = fraction } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun gcpAccountId(gcpAccountId: String) = - gcpAccountId(JsonField.of(gcpAccountId)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - /** - * Sets [Builder.gcpAccountId] to an arbitrary JSON value. - * - * You should usually call [Builder.gcpAccountId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun gcpAccountId(gcpAccountId: JsonField) = apply { - this.gcpAccountId = gcpAccountId - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) + return other is Next && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.gcpOfferId] to an arbitrary JSON value. - * - * You should usually call [Builder.gcpOfferId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun gcpOfferId(gcpOfferId: JsonField) = apply { - this.gcpOfferId = gcpOfferId - } + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) + } - fun netsuiteResellerId(netsuiteResellerId: String) = - netsuiteResellerId(JsonField.of(netsuiteResellerId)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteResellerId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { - this.netsuiteResellerId = netsuiteResellerId + override fun toString() = + "Next{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } - fun resellerContractValue(resellerContractValue: Double) = - resellerContractValue(JsonField.of(resellerContractValue)) + class Previous + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.resellerContractValue] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerContractValue] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun resellerContractValue(resellerContractValue: JsonField) = apply { - this.resellerContractValue = resellerContractValue - } + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [AddResellerRoyalty]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddResellerRoyalty = - AddResellerRoyalty( - checkRequired("resellerType", resellerType), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties.toMutableMap(), - ) - } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Previous]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Previous]. */ + class Builder internal constructor() { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AddResellerRoyalty = apply { - if (validated) { - return@apply - } + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - resellerType().validate() - applicableProductIds() - applicableProductTags() - awsAccountNumber() - awsOfferId() - awsPayerReferenceId() - endingBefore() - fraction() - gcpAccountId() - gcpOfferId() - netsuiteResellerId() - resellerContractValue() - startingAt() - validated = true - } + @JvmSynthetic + internal fun from(previous: Previous) = apply { + endingBefore = previous.endingBefore + startingAt = previous.startingAt + additionalProperties = previous.additionalProperties.toMutableMap() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (resellerType.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + - (if (awsOfferId.asKnown().isPresent) 1 else 0) + - (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (fraction.asKnown().isPresent) 1 else 0) + - (if (gcpAccountId.asKnown().isPresent) 1 else 0) + - (if (gcpOfferId.asKnown().isPresent) 1 else 0) + - (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + - (if (resellerContractValue.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - class ResellerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - companion object { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val AWS = of("AWS") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmField val GCP = of("GCP") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) - } + /** + * Returns an immutable instance of [Previous]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Previous = + Previous( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - /** An enum containing [ResellerType]'s known values. */ - enum class Known { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, - } + private var validated: Boolean = false - /** - * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResellerType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, /** - * An enum member indicating that [ResellerType] was instantiated with an - * unknown value. + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - _UNKNOWN, - } + fun validate(): Previous = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AWS -> Value.AWS - AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE - GCP -> Value.GCP - GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE - else -> Value._UNKNOWN + endingBefore() + startingAt() + validated = true } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - AWS -> Known.AWS - AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE - GCP -> Known.GCP - GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE - else -> - throw MetronomeInvalidDataException("Unknown ResellerType: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): ResellerType = apply { - if (validated) { - return@apply + return other is Previous && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Previous{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ResellerType && value == other.value + return other is BillingPeriods && + current == other.current && + next == other.next && + previous == other.previous && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + private val hashCode: Int by lazy { + Objects.hash(current, next, previous, additionalProperties) } - return other is AddResellerRoyalty && - resellerType == other.resellerType && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - awsAccountNumber == other.awsAccountNumber && - awsOfferId == other.awsOfferId && - awsPayerReferenceId == other.awsPayerReferenceId && - endingBefore == other.endingBefore && - fraction == other.fraction && - gcpAccountId == other.gcpAccountId && - gcpOfferId == other.gcpOfferId && - netsuiteResellerId == other.netsuiteResellerId && - resellerContractValue == other.resellerContractValue && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + override fun hashCode(): Int = hashCode - private val hashCode: Int by lazy { - Objects.hash( - resellerType, - applicableProductIds, - applicableProductTags, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties, - ) + override fun toString() = + "BillingPeriods{current=$current, next=$next, previous=$previous, additionalProperties=$additionalProperties}" } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, endingBefore=$endingBefore, fraction=$fraction, gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } - - class AddScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val product: JsonField, - private val schedule: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val additionalProperties: MutableMap, - ) { - + class CollectionSchedule @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - ) : this(id, product, schedule, name, netsuiteSalesOrderId, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun product(): Product = product.getRequired("product") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun schedule(): SchedulePointInTime = schedule.getRequired("schedule") - - /** - * displayed on invoices - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * This field's availability is dependent on your client's configuration. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product") - @ExcludeMissing - fun _product(): JsonField = product - - /** - * Returns the raw JSON value of [schedule]. - * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - - @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 { + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of - * [AddScheduledCharge]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .id() - * .product() - * .schedule() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { - /** A builder for [AddScheduledCharge]. */ - class Builder internal constructor() { + @JvmField val ADVANCE = of("ADVANCE") - private var id: JsonField? = null - private var product: JsonField? = null - private var schedule: JsonField? = null - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ARREARS = of("ARREARS") - @JvmSynthetic - internal fun from(addScheduledCharge: AddScheduledCharge) = apply { - id = addScheduledCharge.id - product = addScheduledCharge.product - schedule = addScheduledCharge.schedule - name = addScheduledCharge.name - netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId - additionalProperties = - addScheduledCharge.additionalProperties.toMutableMap() + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - fun id(id: String) = id(JsonField.of(id)) + /** An enum containing [CollectionSchedule]'s known values. */ + enum class Known { + ADVANCE, + ARREARS, + } /** - * Sets [Builder.id] to an arbitrary JSON value. + * An enum containing [CollectionSchedule]'s known values, as well as an + * [_UNKNOWN] member. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An instance of [CollectionSchedule] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun id(id: JsonField) = apply { this.id = id } - - fun product(product: Product) = product(JsonField.of(product)) + enum class Value { + ADVANCE, + ARREARS, + /** + * An enum member indicating that [CollectionSchedule] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.product] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. */ - fun product(product: JsonField) = apply { this.product = product } - - fun schedule(schedule: SchedulePointInTime) = schedule(JsonField.of(schedule)) + fun value(): Value = + when (this) { + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS + else -> Value._UNKNOWN + } /** - * Sets [Builder.schedule] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.schedule] with a well-typed - * [SchedulePointInTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. */ - fun schedule(schedule: JsonField) = apply { - this.schedule = schedule - } - - /** displayed on invoices */ - fun name(name: String) = name(JsonField.of(name)) + fun known(): Known = + when (this) { + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException( + "Unknown CollectionSchedule: $value" + ) + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun name(name: JsonField) = apply { this.name = name } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** This field's availability is dependent on your client's configuration. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + private var validated: Boolean = false /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): CollectionSchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .product() - * .schedule() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddScheduledCharge = - AddScheduledCharge( - checkRequired("id", id), - checkRequired("product", product), - checkRequired("schedule", schedule), - name, - netsuiteSalesOrderId, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AddScheduledCharge = apply { - if (validated) { - return@apply + return other is CollectionSchedule && value == other.value } - id() - product().validate() - schedule().validate() - name() - netsuiteSalesOrderId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + override fun toString() = value.toString() + } - class Product + class Proration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val name: JsonField, + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") + @JsonProperty("invoice_behavior") @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun invoiceBehavior(): InvoiceBehavior = + invoiceBehavior.getRequired("invoice_behavior") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun id(): String = id.getRequired("id") + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun name(): String = name.getRequired("name") + fun rounding(): Optional = rounding.getOptional("rounding") /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [invoiceBehavior]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("invoice_behavior") + @ExcludeMissing + fun _invoiceBehavior(): JsonField = invoiceBehavior /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [isProrated]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -15557,1010 +19421,1213 @@ private constructor( fun _additionalProperties(): Map = Collections.unmodifiableMap(additionalProperties) - fun toBuilder() = Builder().from(this) + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Proration]. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Proration]. */ + class Builder internal constructor() { + + private var invoiceBehavior: JsonField? = null + private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() + } + + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) + + /** + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } + + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + + /** + * Sets [Builder.isProrated] to an arbitrary JSON value. + * + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun rounding(rounding: JsonField) = apply { + this.rounding = rounding + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Proration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .invoiceBehavior() + * .isProrated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Proration = + Proration( + checkRequired("invoiceBehavior", invoiceBehavior), + checkRequired("isProrated", isProrated), + rounding, + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + invoiceBehavior().validate() + isProrated() + rounding().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) + + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + + @JvmField + val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } + + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } + + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException( + "Unknown InvoiceBehavior: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [Product]. + * Validates that the types of all values in this object match their + * expected types recursively. * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - @JvmStatic fun builder() = Builder() - } + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - /** A builder for [Product]. */ - class Builder internal constructor() { + known() + validated = true + } - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceBehavior && value == other.value } - fun id(id: String) = id(JsonField.of(id)) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - fun name(name: String) = name(JsonField.of(name)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns the raw JSON value of [decimalPlaces]. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun name(name: JsonField) = apply { this.name = name } + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Rounding]. */ + class Builder internal constructor() { - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - id() - name() - validated = true - } + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - private val hashCode: Int by lazy { - Objects.hash(id, name, additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun hashCode(): Int = hashCode + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - return other is AddScheduledCharge && - id == other.id && - product == other.product && - schedule == other.schedule && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - additionalProperties == other.additionalProperties - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private val hashCode: Int by lazy { - Objects.hash( - id, - product, - schedule, - name, - netsuiteSalesOrderId, - additionalProperties, - ) - } + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "AddScheduledCharge{id=$id, product=$product, schedule=$schedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } - class AddSubscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val billingPeriods: JsonField, - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val quantityManagementMode: JsonField, - private val quantitySchedule: JsonField>, - private val startingAt: JsonField, - private val subscriptionRate: JsonField, - private val id: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val fiatCreditTypeId: JsonField, - private val name: JsonField, - private val seatConfig: JsonField, - private val additionalProperties: MutableMap, - ) { + decimalPlaces() + roundingMethod().validate() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("billing_periods") - @ExcludeMissing - billingPeriods: JsonField = JsonMissing.of(), - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("quantity_schedule") - @ExcludeMissing - quantitySchedule: JsonField> = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fiatCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - ) : this( - billingPeriods, - collectionSchedule, - proration, - quantityManagementMode, - quantitySchedule, - startingAt, - subscriptionRate, - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - mutableMapOf(), - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Previous, current, and next billing periods for the subscription. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun billingPeriods(): BillingPeriods = billingPeriods.getRequired("billing_periods") + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun proration(): Proration = proration.getRequired("proration") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Determines how the subscription's quantity is controlled. Defaults to - * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly - * on the subscription. `initial_quantity` must be provided with this option. - * Compatible with recurring commits/credits that use POOLED allocation. - * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add - * user_123) to increment and decrement a subscription quantity, rather than - * directly providing the quantity. You must use a **SEAT_BASED** subscription to - * use a linked recurring credit with an allocation per seat. `seat_config` must be - * provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun quantityManagementMode(): QuantityManagementMode = - quantityManagementMode.getRequired("quantity_management_mode") + companion object { - /** - * List of quantity schedule items for the subscription. Only includes the current - * quantity and future quantity changes. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun quantitySchedule(): List = - quantitySchedule.getRequired("quantity_schedule") + @JvmField val HALF_UP = of("HALF_UP") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + @JvmField val FLOOR = of("FLOOR") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun subscriptionRate(): SubscriptionRate = - subscriptionRate.getRequired("subscription_rate") + @JvmField val CEILING = of("CEILING") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun customFields(): Optional = - customFields.getOptional("custom_fields") + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun fiatCreditTypeId(): Optional = - fiatCreditTypeId.getOptional("fiat_credit_type_id") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billingPeriods]. - * - * Unlike [billingPeriods], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_periods") - @ExcludeMissing - fun _billingPeriods(): JsonField = billingPeriods + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + known() + validated = true + } - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = - quantityManagementMode + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [quantitySchedule]. - * - * Unlike [quantitySchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_schedule") - @ExcludeMissing - fun _quantitySchedule(): JsonField> = quantitySchedule + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + return other is RoundingMethod && value == other.value + } - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - /** - * Returns the raw JSON value of [fiatCreditTypeId]. - * - * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) + } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" + } + + /** + * Determines how the subscription's quantity is controlled. Defaults to + * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly + * on the subscription. `initial_quantity` must be provided with this option. + * Compatible with recurring commits/credits that use POOLED allocation. + * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add + * user_123) to increment and decrement a subscription quantity, rather than + * directly providing the quantity. You must use a **SEAT_BASED** subscription to + * use a linked recurring credit with an allocation per seat. `seat_config` must be + * provided with this option. + */ + class QuantityManagementMode + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of [AddSubscription]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .billingPeriods() - * .collectionSchedule() - * .proration() - * .quantityManagementMode() - * .quantitySchedule() - * .startingAt() - * .subscriptionRate() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** A builder for [AddSubscription]. */ - class Builder internal constructor() { + companion object { - private var billingPeriods: JsonField? = null - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var quantityManagementMode: JsonField? = null - private var quantitySchedule: JsonField>? = null - private var startingAt: JsonField? = null - private var subscriptionRate: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var fiatCreditTypeId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val SEAT_BASED = of("SEAT_BASED") - @JvmSynthetic - internal fun from(addSubscription: AddSubscription) = apply { - billingPeriods = addSubscription.billingPeriods - collectionSchedule = addSubscription.collectionSchedule - proration = addSubscription.proration - quantityManagementMode = addSubscription.quantityManagementMode - quantitySchedule = - addSubscription.quantitySchedule.map { it.toMutableList() } - startingAt = addSubscription.startingAt - subscriptionRate = addSubscription.subscriptionRate - id = addSubscription.id - customFields = addSubscription.customFields - description = addSubscription.description - endingBefore = addSubscription.endingBefore - fiatCreditTypeId = addSubscription.fiatCreditTypeId - name = addSubscription.name - seatConfig = addSubscription.seatConfig - additionalProperties = addSubscription.additionalProperties.toMutableMap() + @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + + @JvmStatic + fun of(value: String) = QuantityManagementMode(JsonField.of(value)) } - /** Previous, current, and next billing periods for the subscription. */ - fun billingPeriods(billingPeriods: BillingPeriods) = - billingPeriods(JsonField.of(billingPeriods)) + /** An enum containing [QuantityManagementMode]'s known values. */ + enum class Known { + SEAT_BASED, + QUANTITY_ONLY, + } /** - * Sets [Builder.billingPeriods] to an arbitrary JSON value. + * An enum containing [QuantityManagementMode]'s known values, as well as an + * [_UNKNOWN] member. * - * You should usually call [Builder.billingPeriods] with a well-typed - * [BillingPeriods] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * An instance of [QuantityManagementMode] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun billingPeriods(billingPeriods: JsonField) = apply { - this.billingPeriods = billingPeriods + enum class Value { + SEAT_BASED, + QUANTITY_ONLY, + /** + * An enum member indicating that [QuantityManagementMode] was instantiated + * with an unknown value. + */ + _UNKNOWN, } - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SEAT_BASED -> Value.SEAT_BASED + QUANTITY_ONLY -> Value.QUANTITY_ONLY + else -> Value._UNKNOWN + } /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. */ - fun collectionSchedule(collectionSchedule: JsonField) = - apply { - this.collectionSchedule = collectionSchedule + fun known(): Known = + when (this) { + SEAT_BASED -> Known.SEAT_BASED + QUANTITY_ONLY -> Known.QUANTITY_ONLY + else -> + throw MetronomeInvalidDataException( + "Unknown QuantityManagementMode: $value" + ) } - fun proration(proration: Proration) = proration(JsonField.of(proration)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Sets [Builder.proration] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.proration] with a well-typed [Proration] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun proration(proration: JsonField) = apply { - this.proration = proration + fun validate(): QuantityManagementMode = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** - * Determines how the subscription's quantity is controlled. Defaults to - * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified - * directly on the subscription. `initial_quantity` must be provided with this - * option. Compatible with recurring commits/credits that use POOLED allocation. - * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add - * user_123) to increment and decrement a subscription quantity, rather than - * directly providing the quantity. You must use a **SEAT_BASED** subscription - * to use a linked recurring credit with an allocation per seat. `seat_config` - * must be provided with this option. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QuantityManagementMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class QuantitySchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val quantity: JsonField, + private val startingAt: JsonField, + private val endingBefore: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + ) : this(quantity, startingAt, endingBefore, mutableMapOf()) /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun quantityManagementMode( - quantityManagementMode: JsonField - ) = apply { this.quantityManagementMode = quantityManagementMode } + fun quantity(): Double = quantity.getRequired("quantity") /** - * List of quantity schedule items for the subscription. Only includes the - * current quantity and future quantity changes. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun quantitySchedule(quantitySchedule: List) = - quantitySchedule(JsonField.of(quantitySchedule)) + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") /** - * Sets [Builder.quantitySchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.quantitySchedule] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun quantitySchedule(quantitySchedule: JsonField>) = - apply { - this.quantitySchedule = quantitySchedule.map { it.toMutableList() } - } + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** - * Adds a single [QuantitySchedule] to [Builder.quantitySchedule]. + * Returns the raw JSON value of [quantity]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addQuantitySchedule(quantitySchedule: QuantitySchedule) = apply { - this.quantitySchedule = - (this.quantitySchedule ?: JsonField.of(mutableListOf())).also { - checkKnown("quantitySchedule", it).add(quantitySchedule) - } - } - - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Returns the raw JSON value of [startingAt]. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } - - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * Returns the raw JSON value of [endingBefore]. * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun id(id: String) = id(JsonField.of(id)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun toBuilder() = Builder().from(this) - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = - customFields(JsonField.of(customFields)) + companion object { - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed - * [CustomFields] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields + /** + * Returns a mutable builder for constructing an instance of + * [QuantitySchedule]. + * + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun description(description: String) = description(JsonField.of(description)) + /** A builder for [QuantitySchedule]. */ + class Builder internal constructor() { - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + private var quantity: JsonField? = null + private var startingAt: JsonField? = null + private var endingBefore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + @JvmSynthetic + internal fun from(quantitySchedule: QuantitySchedule) = apply { + quantity = quantitySchedule.quantity + startingAt = quantitySchedule.startingAt + endingBefore = quantitySchedule.endingBefore + additionalProperties = + quantitySchedule.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - fun fiatCreditTypeId(fiatCreditTypeId: String) = - fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } - /** - * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { - this.fiatCreditTypeId = fiatCreditTypeId - } + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [QuantitySchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): QuantitySchedule = + QuantitySchedule( + checkRequired("quantity", quantity), + checkRequired("startingAt", startingAt), + endingBefore, + additionalProperties.toMutableMap(), + ) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): QuantitySchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + quantity() + startingAt() + endingBefore() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddSubscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingPeriods() - * .collectionSchedule() - * .proration() - * .quantityManagementMode() - * .quantitySchedule() - * .startingAt() - * .subscriptionRate() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddSubscription = - AddSubscription( - checkRequired("billingPeriods", billingPeriods), - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("quantityManagementMode", quantityManagementMode), - checkRequired("quantitySchedule", quantitySchedule).map { - it.toImmutable() - }, - checkRequired("startingAt", startingAt), - checkRequired("subscriptionRate", subscriptionRate), - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AddSubscription = apply { - if (validated) { - return@apply + return other is QuantitySchedule && + quantity == other.quantity && + startingAt == other.startingAt && + endingBefore == other.endingBefore && + additionalProperties == other.additionalProperties } - billingPeriods().validate() - collectionSchedule().validate() - proration().validate() - quantityManagementMode().validate() - quantitySchedule().forEach { it.validate() } - startingAt() - subscriptionRate().validate() - id() - customFields().ifPresent { it.validate() } - description() - endingBefore() - fiatCreditTypeId() - name() - seatConfig().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(quantity, startingAt, endingBefore, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (billingPeriods.asKnown().getOrNull()?.validity() ?: 0) + - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (quantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + override fun hashCode(): Int = hashCode - /** Previous, current, and next billing periods for the subscription. */ - class BillingPeriods + override fun toString() = + "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + } + + class SubscriptionRate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val current: JsonField, - private val next: JsonField, - private val previous: JsonField, + private val billingFrequency: JsonField, + private val product: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("current") - @ExcludeMissing - current: JsonField = JsonMissing.of(), - @JsonProperty("next") + @JsonProperty("billing_frequency") @ExcludeMissing - next: JsonField = JsonMissing.of(), - @JsonProperty("previous") + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product") @ExcludeMissing - previous: JsonField = JsonMissing.of(), - ) : this(current, next, previous, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun current(): Optional = current.getOptional("current") + product: JsonField = JsonMissing.of(), + ) : this(billingFrequency, product, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun next(): Optional = next.getOptional("next") + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun previous(): Optional = previous.getOptional("previous") + fun product(): Product = product.getRequired("product") /** - * Returns the raw JSON value of [current]. + * Returns the raw JSON value of [billingFrequency]. * - * Unlike [current], this method doesn't throw if the JSON field has an + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("current") + @JsonProperty("billing_frequency") @ExcludeMissing - fun _current(): JsonField = current - - /** - * Returns the raw JSON value of [next]. - * - * Unlike [next], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("next") @ExcludeMissing fun _next(): JsonField = next + fun _billingFrequency(): JsonField = billingFrequency /** - * Returns the raw JSON value of [previous]. + * Returns the raw JSON value of [product]. * - * Unlike [previous], this method doesn't throw if the JSON field has an + * Unlike [product], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("previous") + @JsonProperty("product") @ExcludeMissing - fun _previous(): JsonField = previous + fun _product(): JsonField = product @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -16578,63 +20645,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BillingPeriods]. + * [SubscriptionRate]. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingPeriods]. */ + /** A builder for [SubscriptionRate]. */ class Builder internal constructor() { - private var current: JsonField = JsonMissing.of() - private var next: JsonField = JsonMissing.of() - private var previous: JsonField = JsonMissing.of() + private var billingFrequency: JsonField? = null + private var product: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingPeriods: BillingPeriods) = apply { - current = billingPeriods.current - next = billingPeriods.next - previous = billingPeriods.previous + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + product = subscriptionRate.product additionalProperties = - billingPeriods.additionalProperties.toMutableMap() + subscriptionRate.additionalProperties.toMutableMap() } - fun current(current: Current) = current(JsonField.of(current)) - - /** - * Sets [Builder.current] to an arbitrary JSON value. - * - * You should usually call [Builder.current] with a well-typed [Current] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun current(current: JsonField) = apply { this.current = current } - - fun next(next: Next) = next(JsonField.of(next)) + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Sets [Builder.next] to an arbitrary JSON value. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * You should usually call [Builder.next] with a well-typed [Next] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun next(next: JsonField) = apply { this.next = next } + fun billingFrequency(billingFrequency: JsonField) = + apply { + this.billingFrequency = billingFrequency + } - fun previous(previous: Previous) = previous(JsonField.of(previous)) + fun product(product: Product) = product(JsonField.of(product)) /** - * Sets [Builder.previous] to an arbitrary JSON value. + * Sets [Builder.product] to an arbitrary JSON value. * - * You should usually call [Builder.previous] with a well-typed [Previous] + * You should usually call [Builder.product] with a well-typed [Product] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun previous(previous: JsonField) = apply { - this.previous = previous - } + fun product(product: JsonField) = apply { this.product = product } fun additionalProperties(additionalProperties: Map) = apply { @@ -16659,15 +20721,22 @@ private constructor( } /** - * Returns an immutable instance of [BillingPeriods]. + * Returns an immutable instance of [SubscriptionRate]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): BillingPeriods = - BillingPeriods( - current, - next, - previous, + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("product", product), additionalProperties.toMutableMap(), ) } @@ -16684,14 +20753,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): BillingPeriods = apply { + fun validate(): SubscriptionRate = apply { if (validated) { return@apply } - current().ifPresent { it.validate() } - next().ifPresent { it.validate() } - previous().ifPresent { it.validate() } + billingFrequency().validate() + product().validate() validated = true } @@ -16711,176 +20779,119 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (current.asKnown().getOrNull()?.validity() ?: 0) + - (next.asKnown().getOrNull()?.validity() ?: 0) + - (previous.asKnown().getOrNull()?.validity() ?: 0) - - class Current - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + class BillingFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns the raw JSON value of [startingAt]. + * Returns this class instance's raw value. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt - - @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) + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** - * Returns a mutable builder for constructing an instance of [Current]. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Current]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("MONTHLY") - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + @JvmField val QUARTERLY = of("QUARTERLY") - @JvmSynthetic - internal fun from(current: Current) = apply { - endingBefore = current.endingBefore - startingAt = current.startingAt - additionalProperties = current.additionalProperties.toMutableMap() - } + @JvmField val ANNUAL = of("ANNUAL") - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + @JvmField val WEEKLY = of("WEEKLY") - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } + /** + * An enum containing [BillingFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BillingFrequency] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * An enum member indicating that [BillingFrequency] was instantiated + * with an unknown value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException( + "Unknown BillingFrequency: $value" + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [Current]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Current = - Current( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false /** @@ -16893,13 +20904,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Current = apply { + fun validate(): BillingFrequency = apply { if (validated) { return@apply } - endingBefore() - startingAt() + known() validated = true } @@ -16918,83 +20928,68 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Current && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) + return other is BillingFrequency && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Current{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Next + class Product @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val id: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("ending_before") + @JsonProperty("id") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) + name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") + fun id(): String = id.getRequired("id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [id]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * Unlike [id], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [name]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an + * Unlike [name], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17011,59 +21006,53 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Next]. + * Returns a mutable builder for constructing an instance of [Product]. * * The following fields are required: * ```java - * .endingBefore() - * .startingAt() + * .id() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Next]. */ + /** A builder for [Product]. */ class Builder internal constructor() { - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(next: Next) = apply { - endingBefore = next.endingBefore - startingAt = next.startingAt - additionalProperties = next.additionalProperties.toMutableMap() + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun id(id: JsonField) = apply { this.id = id } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -17088,23 +21077,23 @@ private constructor( } /** - * Returns an immutable instance of [Next]. + * Returns an immutable instance of [Product]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .endingBefore() - * .startingAt() + * .id() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Next = - Next( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -17121,13 +21110,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Next = apply { + fun validate(): Product = apply { if (validated) { return@apply } - endingBefore() - startingAt() + id() + name() validated = true } @@ -17147,196 +21136,372 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Next && - endingBefore == other.endingBefore && - startingAt == other.startingAt && + return other is Product && + id == other.id && + name == other.name && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) + Objects.hash(id, name, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Next{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + product == other.product && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(billingFrequency, product, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + } + + class BillingCycleConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("anchor_date") + @ExcludeMissing + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") + @ExcludeMissing + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) + + /** + * The date this subscription's billing cycle is anchored to. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun anchorDate(): OffsetDateTime = anchorDate.getRequired("anchor_date") + + /** + * Controls whether this subscription consolidates onto usage invoices or gets + * its own scheduled invoice. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun invoicePlacement(): InvoicePlacement = + invoicePlacement.getRequired("invoice_placement") + + /** + * Returns the raw JSON value of [anchorDate]. + * + * Unlike [anchorDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("anchor_date") + @ExcludeMissing + fun _anchorDate(): JsonField = anchorDate + + /** + * Returns the raw JSON value of [invoicePlacement]. + * + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_placement") + @ExcludeMissing + fun _invoicePlacement(): JsonField = invoicePlacement + + @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 + * [BillingCycleConfig]. + * + * The following fields are required: + * ```java + * .anchorDate() + * .invoicePlacement() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Previous - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + /** A builder for [BillingCycleConfig]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) + private var anchorDate: JsonField? = null + private var invoicePlacement: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") + @JvmSynthetic + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = + billingCycleConfig.additionalProperties.toMutableMap() + } + + /** The date this subscription's billing cycle is anchored to. */ + fun anchorDate(anchorDate: OffsetDateTime) = + anchorDate(JsonField.of(anchorDate)) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * Sets [Builder.anchorDate] to an arbitrary JSON value. + * + * You should usually call [Builder.anchorDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate + } /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * Controls whether this subscription consolidates onto usage invoices or + * gets its own scheduled invoice. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Returns the raw JSON value of [startingAt]. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun invoicePlacement(invoicePlacement: JsonField) = + apply { + this.invoicePlacement = invoicePlacement + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - companion object { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns a mutable builder for constructing an instance of [Previous]. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** A builder for [Previous]. */ - class Builder internal constructor() { + /** + * Returns an immutable instance of [BillingCycleConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .anchorDate() + * .invoicePlacement() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingCycleConfig = + BillingCycleConfig( + checkRequired("anchorDate", anchorDate), + checkRequired("invoicePlacement", invoicePlacement), + additionalProperties.toMutableMap(), + ) + } - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(previous: Previous) = apply { - endingBefore = previous.endingBefore - startingAt = previous.startingAt - additionalProperties = previous.additionalProperties.toMutableMap() - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): BillingCycleConfig = apply { + if (validated) { + return@apply + } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + anchorDate() + invoicePlacement().validate() + validated = true + } - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * Controls whether this subscription consolidates onto usage invoices or gets + * its own scheduled invoice. + */ + class InvoicePlacement + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) + } + + /** An enum containing [InvoicePlacement]'s known values. */ + enum class Known { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, + } + /** + * An enum containing [InvoicePlacement]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [InvoicePlacement] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * Returns an immutable instance of [Previous]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [InvoicePlacement] was instantiated + * with an unknown value. */ - fun build(): Previous = - Previous( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE + else -> + throw MetronomeInvalidDataException( + "Unknown InvoicePlacement: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -17349,13 +21514,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Previous = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } - endingBefore() - startingAt() + known() validated = true } @@ -17374,29 +21538,19 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Previous && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) + return other is InvoicePlacement && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Previous{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -17404,291 +21558,53 @@ private constructor( return true } - return other is BillingPeriods && - current == other.current && - next == other.next && - previous == other.previous && + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(current, next, previous, additionalProperties) + Objects.hash(anchorDate, invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BillingPeriods{current=$current, next=$next, previous=$previous, additionalProperties=$additionalProperties}" + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" } - class CollectionSchedule + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ADVANCE = of("ADVANCE") - - @JvmField val ARREARS = of("ARREARS") - - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } - - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } - - /** - * An enum containing [CollectionSchedule]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException( - "Unknown CollectionSchedule: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CollectionSchedule && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Proration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("invoice_behavior") - @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") - @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun invoiceBehavior(): InvoiceBehavior = - invoiceBehavior.getRequired("invoice_behavior") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") - - /** - * Returns the raw JSON value of [invoiceBehavior]. - * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_behavior") - @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior - - /** - * Returns the raw JSON value of [isProrated]. - * - * Unlike [isProrated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("is_prorated") - @ExcludeMissing - fun _isProrated(): JsonField = isProrated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [Proration]. - * - * The following fields are required: - * ```java - * .invoiceBehavior() - * .isProrated() - * ``` + * Returns a mutable builder for constructing an instance of [CustomFields]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [CustomFields]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField? = null - private var isProrated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() - } - - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) - - /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior - } - - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) - - /** - * Sets [Builder.isProrated] to an arbitrary JSON value. - * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -17714,24 +21630,11 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [CustomFields]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceBehavior() - * .isProrated() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration( - checkRequired("invoiceBehavior", invoiceBehavior), - checkRequired("isProrated", isProrated), - additionalProperties.toMutableMap(), - ) + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) } private var validated: Boolean = false @@ -17746,13 +21649,11 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Proration = apply { + fun validate(): CustomFields = apply { if (validated) { return@apply } - invoiceBehavior().validate() - isProrated() validated = true } @@ -17772,1796 +21673,1979 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFields{additionalProperties=$additionalProperties}" + } + + class SeatConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val seatGroupKey: JsonField, + private val additionalProperties: MutableMap, + ) { - class InvoiceBehavior @JsonCreator - private constructor(private val value: JsonField) : Enum { + private constructor( + @JsonProperty("seat_group_key") + @ExcludeMissing + seatGroupKey: JsonField = JsonMissing.of() + ) : this(seatGroupKey, mutableMapOf()) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * The property name, sent on usage events, that identifies the seat ID + * associated with the usage event. For example, the property name might be + * seat_id or user_id. The property must be set as a group key on billable + * metrics and a presentation/pricing group key on contract products. This + * allows linked recurring credits with an allocation per seat to be consumed by + * only one seat's usage. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") - companion object { + /** + * Returns the raw JSON value of [seatGroupKey]. + * + * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("seat_group_key") + @ExcludeMissing + fun _seatGroupKey(): JsonField = seatGroupKey - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField - val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [InvoiceBehavior]'s known values. */ - enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - } + companion object { /** - * An enum containing [InvoiceBehavior]'s known values, as well as an - * [_UNKNOWN] member. + * Returns a mutable builder for constructing an instance of [SeatConfig]. * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * The following fields are required: + * ```java + * .seatGroupKey() + * ``` */ - enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, - /** - * An enum member indicating that [InvoiceBehavior] was instantiated - * with an unknown value. - */ - _UNKNOWN, - } + @JvmStatic fun builder() = Builder() + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE - else -> Value._UNKNOWN - } + /** A builder for [SeatConfig]. */ + class Builder internal constructor() { - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE - else -> - throw MetronomeInvalidDataException( - "Unknown InvoiceBehavior: $value" - ) - } + private var seatGroupKey: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(seatConfig: SeatConfig) = apply { + seatGroupKey = seatConfig.seatGroupKey + additionalProperties = seatConfig.additionalProperties.toMutableMap() + } /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. + * The property name, sent on usage events, that identifies the seat ID + * associated with the usage event. For example, the property name might be + * seat_id or user_id. The property must be set as a group key on billable + * metrics and a presentation/pricing group key on contract products. This + * allows linked recurring credits with an allocation per seat to be + * consumed by only one seat's usage. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + fun seatGroupKey(seatGroupKey: String) = + seatGroupKey(JsonField.of(seatGroupKey)) /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Sets [Builder.seatGroupKey] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): InvoiceBehavior = apply { - if (validated) { - return@apply + * You should usually call [Builder.seatGroupKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun seatGroupKey(seatGroupKey: JsonField) = apply { + this.seatGroupKey = seatGroupKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - known() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [SeatConfig]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .seatGroupKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): SeatConfig = + SeatConfig( + checkRequired("seatGroupKey", seatGroupKey), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is InvoiceBehavior && value == other.value + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): SeatConfig = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + seatGroupKey() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (seatGroupKey.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is SeatConfig && + seatGroupKey == other.seatGroupKey && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(seatGroupKey, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" + "SeatConfig{seatGroupKey=$seatGroupKey, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddSubscription && + billingPeriods == other.billingPeriods && + collectionSchedule == other.collectionSchedule && + proration == other.proration && + quantityManagementMode == other.quantityManagementMode && + quantitySchedule == other.quantitySchedule && + startingAt == other.startingAt && + subscriptionRate == other.subscriptionRate && + id == other.id && + billingCycleConfig == other.billingCycleConfig && + customFields == other.customFields && + description == other.description && + endingBefore == other.endingBefore && + fiatCreditTypeId == other.fiatCreditTypeId && + name == other.name && + seatConfig == other.seatConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + billingPeriods, + collectionSchedule, + proration, + quantityManagementMode, + quantitySchedule, + startingAt, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + additionalProperties, + ) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddSubscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" + } + + class AddUsageFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupKey: JsonField, + private val groupValues: JsonField>, + private val startingAt: JsonField, + private val endingBefore: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("group_key") + @ExcludeMissing + groupKey: JsonField = JsonMissing.of(), + @JsonProperty("group_values") + @ExcludeMissing + groupValues: JsonField> = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + ) : this(groupKey, groupValues, startingAt, endingBefore, mutableMapOf()) + /** - * Determines how the subscription's quantity is controlled. Defaults to - * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly - * on the subscription. `initial_quantity` must be provided with this option. - * Compatible with recurring commits/credits that use POOLED allocation. - * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add - * user_123) to increment and decrement a subscription quantity, rather than - * directly providing the quantity. You must use a **SEAT_BASED** subscription to - * use a linked recurring credit with an allocation per seat. `seat_config` must be - * provided with this option. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - class QuantityManagementMode - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun groupKey(): String = groupKey.getRequired("group_key") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupValues(): List = groupValues.getRequired("group_values") - companion object { + /** + * This will match contract starting_at value if usage filter is active from the + * beginning of the contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - @JvmField val SEAT_BASED = of("SEAT_BASED") + /** + * This will match contract ending_before value if usage filter is active until the + * end of the contract. It will be undefined if the contract is open-ended. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + /** + * Returns the raw JSON value of [groupKey]. + * + * Unlike [groupKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group_key") + @ExcludeMissing + fun _groupKey(): JsonField = groupKey + + /** + * Returns the raw JSON value of [groupValues]. + * + * Unlike [groupValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_values") + @ExcludeMissing + fun _groupValues(): JsonField> = groupValues + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - @JvmStatic - fun of(value: String) = QuantityManagementMode(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** An enum containing [QuantityManagementMode]'s known values. */ - enum class Known { - SEAT_BASED, - QUANTITY_ONLY, - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An enum containing [QuantityManagementMode]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [QuantityManagementMode] can contain an unknown value in a - * couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEAT_BASED, - QUANTITY_ONLY, - /** - * An enum member indicating that [QuantityManagementMode] was instantiated - * with an unknown value. - */ - _UNKNOWN, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEAT_BASED -> Value.SEAT_BASED - QUANTITY_ONLY -> Value.QUANTITY_ONLY - else -> Value._UNKNOWN - } + fun toBuilder() = Builder().from(this) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - SEAT_BASED -> Known.SEAT_BASED - QUANTITY_ONLY -> Known.QUANTITY_ONLY - else -> - throw MetronomeInvalidDataException( - "Unknown QuantityManagementMode: $value" - ) - } + companion object { /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns a mutable builder for constructing an instance of [AddUsageFilter]. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * The following fields are required: + * ```java + * .groupKey() + * .groupValues() + * .startingAt() + * ``` */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [AddUsageFilter]. */ + class Builder internal constructor() { - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): QuantityManagementMode = apply { - if (validated) { - return@apply - } + private var groupKey: JsonField? = null + private var groupValues: JsonField>? = null + private var startingAt: JsonField? = null + private var endingBefore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - known() - validated = true + @JvmSynthetic + internal fun from(addUsageFilter: AddUsageFilter) = apply { + groupKey = addUsageFilter.groupKey + groupValues = addUsageFilter.groupValues.map { it.toMutableList() } + startingAt = addUsageFilter.startingAt + endingBefore = addUsageFilter.endingBefore + additionalProperties = addUsageFilter.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun groupKey(groupKey: String) = groupKey(JsonField.of(groupKey)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.groupKey] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.groupKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is QuantityManagementMode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class QuantitySchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val quantity: JsonField, - private val startingAt: JsonField, - private val endingBefore: JsonField, - private val additionalProperties: MutableMap, - ) { + fun groupKey(groupKey: JsonField) = apply { this.groupKey = groupKey } - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - ) : this(quantity, startingAt, endingBefore, mutableMapOf()) + fun groupValues(groupValues: List) = + groupValues(JsonField.of(groupValues)) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * Sets [Builder.groupValues] to an arbitrary JSON value. + * + * You should usually call [Builder.groupValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun quantity(): Double = quantity.getRequired("quantity") + fun groupValues(groupValues: JsonField>) = apply { + this.groupValues = groupValues.map { it.toMutableList() } + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * Adds a single [String] to [groupValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun addGroupValue(groupValue: String) = apply { + groupValues = + (groupValues ?: JsonField.of(mutableListOf())).also { + checkKnown("groupValues", it).add(groupValue) + } + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * This will match contract starting_at value if usage filter is active from the + * beginning of the contract. */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Returns the raw JSON value of [quantity]. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * This will match contract ending_before value if usage filter is active until + * the end of the contract. It will be undefined if the contract is open-ended. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Returns the raw JSON value of [endingBefore]. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns a mutable builder for constructing an instance of - * [QuantitySchedule]. - * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** A builder for [QuantitySchedule]. */ - class Builder internal constructor() { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private var quantity: JsonField? = null - private var startingAt: JsonField? = null - private var endingBefore: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns an immutable instance of [AddUsageFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupKey() + * .groupValues() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddUsageFilter = + AddUsageFilter( + checkRequired("groupKey", groupKey), + checkRequired("groupValues", groupValues).map { it.toImmutable() }, + checkRequired("startingAt", startingAt), + endingBefore, + additionalProperties.toMutableMap(), + ) + } - @JvmSynthetic - internal fun from(quantitySchedule: QuantitySchedule) = apply { - quantity = quantitySchedule.quantity - startingAt = quantitySchedule.startingAt - endingBefore = quantitySchedule.endingBefore - additionalProperties = - quantitySchedule.additionalProperties.toMutableMap() - } + private var validated: Boolean = false - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AddUsageFilter = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } + groupKey() + groupValues() + startingAt() + endingBefore() + validated = true + } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupKey.asKnown().isPresent) 1 else 0) + + (groupValues.asKnown().getOrNull()?.size ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + return other is AddUsageFilter && + groupKey == other.groupKey && + groupValues == other.groupValues && + startingAt == other.startingAt && + endingBefore == other.endingBefore && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + groupKey, + groupValues, + startingAt, + endingBefore, + additionalProperties, + ) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun toString() = + "AddUsageFilter{groupKey=$groupKey, groupValues=$groupValues, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + class ArchiveCommit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * Returns an immutable instance of [QuantitySchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): QuantitySchedule = - QuantitySchedule( - checkRequired("quantity", quantity), - checkRequired("startingAt", startingAt), - endingBefore, - additionalProperties.toMutableMap(), - ) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - private var validated: Boolean = false + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): QuantitySchedule = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - quantity() - startingAt() - endingBefore() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of [ArchiveCommit]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .id() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + @JvmStatic fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [ArchiveCommit]. */ + class Builder internal constructor() { - return other is QuantitySchedule && - quantity == other.quantity && - startingAt == other.startingAt && - endingBefore == other.endingBefore && - additionalProperties == other.additionalProperties - } + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - private val hashCode: Int by lazy { - Objects.hash(quantity, startingAt, endingBefore, additionalProperties) + @JvmSynthetic + internal fun from(archiveCommit: ArchiveCommit) = apply { + id = archiveCommit.id + additionalProperties = archiveCommit.additionalProperties.toMutableMap() } - override fun hashCode(): Int = hashCode + fun id(id: String) = id(JsonField.of(id)) - override fun toString() = - "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - class SubscriptionRate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val billingFrequency: JsonField, - private val product: JsonField, - private val additionalProperties: MutableMap, - ) { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonCreator - private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - ) : this(billingFrequency, product, mutableMapOf()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun product(): Product = product.getRequired("product") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [billingFrequency]. - * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_frequency") - @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns the raw JSON value of [product]. + * Returns an immutable instance of [ArchiveCommit]. * - * Unlike [product], this method doesn't throw if the JSON field has an - * unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JsonProperty("product") - @ExcludeMissing - fun _product(): JsonField = product + fun build(): ArchiveCommit = + ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ArchiveCommit = apply { + if (validated) { + return@apply } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + id() + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - /** - * Returns a mutable builder for constructing an instance of - * [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [SubscriptionRate]. */ - class Builder internal constructor() { + return other is ArchiveCommit && + id == other.id && + additionalProperties == other.additionalProperties + } - private var billingFrequency: JsonField? = null - private var product: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - product = subscriptionRate.product - additionalProperties = - subscriptionRate.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) + override fun toString() = + "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun billingFrequency(billingFrequency: JsonField) = - apply { - this.billingFrequency = billingFrequency - } + class ArchiveCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - fun product(product: Product) = product(JsonField.of(product)) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun product(product: JsonField) = apply { this.product = product } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of [ArchiveCredit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [ArchiveCredit]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [SubscriptionRate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("product", product), - additionalProperties.toMutableMap(), - ) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(archiveCredit: ArchiveCredit) = apply { + id = archiveCredit.id + additionalProperties = archiveCredit.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun id(id: String) = id(JsonField.of(id)) /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun validate(): SubscriptionRate = apply { - if (validated) { - return@apply - } + fun id(id: JsonField) = apply { this.id = id } - billingFrequency().validate() - product().validate() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [ArchiveCredit]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) - - class BillingFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun build(): ArchiveCredit = + ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) + } - @JvmField val MONTHLY = of("MONTHLY") + private var validated: Boolean = false - @JvmField val QUARTERLY = of("QUARTERLY") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ArchiveCredit = apply { + if (validated) { + return@apply + } - @JvmField val ANNUAL = of("ANNUAL") + id() + validated = true + } - @JvmField val WEEKLY = of("WEEKLY") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - /** An enum containing [BillingFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * An enum containing [BillingFrequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [BillingFrequency] can contain an unknown value in a - * couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [BillingFrequency] was instantiated - * with an unknown value. - */ - _UNKNOWN, - } + return other is ArchiveCredit && + id == other.id && + additionalProperties == other.additionalProperties + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown BillingFrequency: $value" - ) - } + override fun hashCode(): Int = hashCode - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + override fun toString() = + "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + class ArchiveScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): BillingFrequency = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - known() - validated = true - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - return other is BillingFrequency && value == other.value - } + fun toBuilder() = Builder().from(this) - override fun hashCode() = value.hashCode() + companion object { - override fun toString() = value.toString() - } + /** + * Returns a mutable builder for constructing an instance of + * [ArchiveScheduledCharge]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { + /** A builder for [ArchiveScheduledCharge]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun id(): String = id.getRequired("id") + @JvmSynthetic + internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { + id = archiveScheduledCharge.id + additionalProperties = + archiveScheduledCharge.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun name(): String = name.getRequired("name") + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun toBuilder() = Builder().from(this) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - companion object { + /** + * Returns an immutable instance of [ArchiveScheduledCharge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArchiveScheduledCharge = + ArchiveScheduledCharge( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [Product]. */ - class Builder internal constructor() { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ArchiveScheduledCharge = apply { + if (validated) { + return@apply + } - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun id(id: String) = id(JsonField.of(id)) + return other is ArchiveScheduledCharge && + id == other.id && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - fun name(name: String) = name(JsonField.of(name)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + override fun toString() = + "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + class RemoveOverride + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } + companion object { - id() - name() - validated = true - } + /** + * Returns a mutable builder for constructing an instance of [RemoveOverride]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** A builder for [RemoveOverride]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun from(removeOverride: RemoveOverride) = apply { + id = removeOverride.id + additionalProperties = removeOverride.additionalProperties.toMutableMap() + } - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } + fun id(id: String) = id(JsonField.of(id)) - private val hashCode: Int by lazy { - Objects.hash(id, name, additionalProperties) - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - override fun hashCode(): Int = hashCode + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - product == other.product && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(billingFrequency, product, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [RemoveOverride]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveOverride = + RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RemoveOverride = apply { + if (validated) { + return@apply + } - companion object { + id() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [CustomFields]. - */ - @JvmStatic fun builder() = Builder() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - private var additionalProperties: MutableMap = - mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + return other is RemoveOverride && + id == other.id && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun toString() = + "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + class UpdateCommit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val invoiceSchedule: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") + @ExcludeMissing + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("invoice_schedule") + @ExcludeMissing + invoiceSchedule: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + mutableMapOf(), + ) - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - private var validated: Boolean = false + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + /** + * Which products the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - validated = true - } + /** + * Which tags the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** - * Returns 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() - } + /** + * Optional configuration for commit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invoiceSchedule(): Optional = + invoiceSchedule.getOptional("invoice_schedule") - return other is CustomFields && - additionalProperties == other.additionalProperties - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - override fun hashCode(): Int = hashCode + /** + * If multiple commits are applicable, the one with the lower priority will apply + * first. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - override fun toString() = - "CustomFields{additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - class SeatConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val seatGroupKey: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * If set, the commit's rate type was updated to the specified value. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") - @JsonCreator - private constructor( - @JsonProperty("seat_group_key") - @ExcludeMissing - seatGroupKey: JsonField = JsonMissing.of() - ) : this(seatGroupKey, mutableMapOf()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") - /** - * The property name, sent on usage events, that identifies the seat ID - * associated with the usage event. For example, the property name might be - * seat_id or user_id. The property must be set as a group key on billable - * metrics and a presentation/pricing group key on contract products. This - * allows linked recurring credits with an allocation per seat to be consumed by - * only one seat's usage. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") - /** - * Returns the raw JSON value of [seatGroupKey]. - * - * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("seat_group_key") - @ExcludeMissing - fun _seatGroupKey(): JsonField = seatGroupKey + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - companion object { + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** - * Returns a mutable builder for constructing an instance of [SeatConfig]. - * - * The following fields are required: - * ```java - * .seatGroupKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration - /** A builder for [SeatConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [invoiceSchedule]. + * + * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_schedule") + @ExcludeMissing + fun _invoiceSchedule(): JsonField = invoiceSchedule - private var seatGroupKey: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(seatConfig: SeatConfig) = apply { - seatGroupKey = seatConfig.seatGroupKey - additionalProperties = seatConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - /** - * The property name, sent on usage events, that identifies the seat ID - * associated with the usage event. For example, the property name might be - * seat_id or user_id. The property must be set as a group key on billable - * metrics and a presentation/pricing group key on contract products. This - * allows linked recurring credits with an allocation per seat to be - * consumed by only one seat's usage. - */ - fun seatGroupKey(seatGroupKey: String) = - seatGroupKey(JsonField.of(seatGroupKey)) + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") + @ExcludeMissing + fun _priority(): JsonField = priority - /** - * Sets [Builder.seatGroupKey] to an arbitrary JSON value. - * - * You should usually call [Builder.seatGroupKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun seatGroupKey(seatGroupKey: JsonField) = apply { - this.seatGroupKey = seatGroupKey - } + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [SeatConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .seatGroupKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SeatConfig = - SeatConfig( - checkRequired("seatGroupKey", seatGroupKey), - additionalProperties.toMutableMap(), - ) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Returns a mutable builder for constructing an instance of [UpdateCommit]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * The following fields are required: + * ```java + * .id() + * ``` */ - fun validate(): SeatConfig = apply { - if (validated) { - return@apply - } + @JvmStatic fun builder() = Builder() + } - seatGroupKey() - validated = true + /** A builder for [UpdateCommit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var invoiceSchedule: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateCommit: UpdateCommit) = apply { + id = updateCommit.id + accessSchedule = updateCommit.accessSchedule + applicableProductIds = + updateCommit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCommit.applicableProductTags.map { it.toMutableList() } + description = updateCommit.description + hierarchyConfiguration = updateCommit.hierarchyConfiguration + invoiceSchedule = updateCommit.invoiceSchedule + name = updateCommit.name + netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId + priority = updateCommit.priority + productId = updateCommit.productId + rateType = updateCommit.rateType + rolloverFraction = updateCommit.rolloverFraction + specifiers = updateCommit.specifiers.map { it.toMutableList() } + additionalProperties = updateCommit.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun id(id: String) = id(JsonField.of(id)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.id] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = (if (seatGroupKey.asKnown().isPresent) 1 else 0) + fun id(id: JsonField) = apply { this.id = id } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) - return other is SeatConfig && - seatGroupKey == other.seatGroupKey && - additionalProperties == other.additionalProperties + /** + * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.accessSchedule] with a well-typed + * [AccessSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule } - private val hashCode: Int by lazy { - Objects.hash(seatGroupKey, additionalProperties) - } + /** + * Which products the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to + * all products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - override fun toString() = - "SeatConfig{seatGroupKey=$seatGroupKey, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = + apply { + this.applicableProductIds = + applicableProductIds.map { it.toMutableList() } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } } - return other is AddSubscription && - billingPeriods == other.billingPeriods && - collectionSchedule == other.collectionSchedule && - proration == other.proration && - quantityManagementMode == other.quantityManagementMode && - quantitySchedule == other.quantitySchedule && - startingAt == other.startingAt && - subscriptionRate == other.subscriptionRate && - id == other.id && - customFields == other.customFields && - description == other.description && - endingBefore == other.endingBefore && - fiatCreditTypeId == other.fiatCreditTypeId && - name == other.name && - seatConfig == other.seatConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - billingPeriods, - collectionSchedule, - proration, - quantityManagementMode, - quantitySchedule, - startingAt, - subscriptionRate, - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddSubscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" - } - - class AddUsageFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val groupKey: JsonField, - private val groupValues: JsonField>, - private val startingAt: JsonField, - private val endingBefore: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("group_key") - @ExcludeMissing - groupKey: JsonField = JsonMissing.of(), - @JsonProperty("group_values") - @ExcludeMissing - groupValues: JsonField> = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - ) : this(groupKey, groupValues, startingAt, endingBefore, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupKey(): String = groupKey.getRequired("group_key") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupValues(): List = groupValues.getRequired("group_values") + /** + * Which tags the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to + * all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - /** - * This will match contract starting_at value if usage filter is active from the - * beginning of the contract. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - /** - * This will match contract ending_before value if usage filter is active until the - * end of the contract. It will be undefined if the contract is open-ended. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = + apply { + this.applicableProductTags = + applicableProductTags.map { it.toMutableList() } + } - /** - * Returns the raw JSON value of [groupKey]. - * - * Unlike [groupKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("group_key") - @ExcludeMissing - fun _groupKey(): JsonField = groupKey + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } - /** - * Returns the raw JSON value of [groupValues]. - * - * Unlike [groupValues], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("group_values") - @ExcludeMissing - fun _groupValues(): JsonField> = groupValues + fun description(description: String) = description(JsonField.of(description)) - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + /** Optional configuration for commit hierarchy access control */ + fun hierarchyConfiguration( + hierarchyConfiguration: CommitHierarchyConfiguration + ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = + invoiceSchedule(JsonField.of(invoiceSchedule)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSchedule] with a well-typed + * [InvoiceSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoiceSchedule(invoiceSchedule: JsonField) = apply { + this.invoiceSchedule = invoiceSchedule + } - companion object { + fun name(name: String) = name(JsonField.of(name)) /** - * Returns a mutable builder for constructing an instance of [AddUsageFilter]. + * Sets [Builder.name] to an arbitrary JSON value. * - * The following fields are required: - * ```java - * .groupKey() - * .groupValues() - * .startingAt() - * ``` + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JvmStatic fun builder() = Builder() - } + fun name(name: JsonField) = apply { this.name = name } - /** A builder for [AddUsageFilter]. */ - class Builder internal constructor() { + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) - private var groupKey: JsonField? = null - private var groupValues: JsonField>? = null - private var startingAt: JsonField? = null - private var endingBefore: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) - @JvmSynthetic - internal fun from(addUsageFilter: AddUsageFilter) = apply { - groupKey = addUsageFilter.groupKey - groupValues = addUsageFilter.groupValues.map { it.toMutableList() } - startingAt = addUsageFilter.startingAt - endingBefore = addUsageFilter.endingBefore - additionalProperties = addUsageFilter.additionalProperties.toMutableMap() + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId } - fun groupKey(groupKey: String) = groupKey(JsonField.of(groupKey)) + /** + * If multiple commits are applicable, the one with the lower priority will + * apply first. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) /** - * Sets [Builder.groupKey] to an arbitrary JSON value. + * Alias for [Builder.priority]. * - * You should usually call [Builder.groupKey] with a well-typed [String] value + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) + + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun groupKey(groupKey: JsonField) = apply { this.groupKey = groupKey } + fun priority(priority: JsonField) = apply { this.priority = priority } - fun groupValues(groupValues: List) = - groupValues(JsonField.of(groupValues)) + fun productId(productId: String) = productId(JsonField.of(productId)) /** - * Sets [Builder.groupValues] to an arbitrary JSON value. + * Sets [Builder.productId] to an arbitrary JSON value. * - * You should usually call [Builder.groupValues] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun groupValues(groupValues: JsonField>) = apply { - this.groupValues = groupValues.map { it.toMutableList() } + fun productId(productId: JsonField) = apply { + this.productId = productId } + /** If set, the commit's rate type was updated to the specified value. */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** - * Adds a single [String] to [groupValues]. + * Sets [Builder.rateType] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addGroupValue(groupValue: String) = apply { - groupValues = - (groupValues ?: JsonField.of(mutableListOf())).also { - checkKnown("groupValues", it).add(groupValue) - } + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) + + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) + + /** + * Alias for calling [Builder.rolloverFraction] with + * `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction } /** - * This will match contract starting_at value if usage filter is active from the - * beginning of the contract. + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at least + * one of the specifiers to contribute to a commit's or credit's drawdown. This + * field cannot be used together with `applicable_product_ids` or + * `applicable_product_tags`. Instead, to target usage by product or product + * tag, pass those values in the body of `specifiers`. */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) + + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.specifiers] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } } /** - * This will match contract ending_before value if usage filter is active until - * the end of the contract. It will be undefined if the contract is open-ended. - */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) - - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Adds a single [CommitSpecifierInput] to [specifiers]. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -19587,25 +23671,33 @@ private constructor( } /** - * Returns an immutable instance of [AddUsageFilter]. + * Returns an immutable instance of [UpdateCommit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupKey() - * .groupValues() - * .startingAt() + * .id() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddUsageFilter = - AddUsageFilter( - checkRequired("groupKey", groupKey), - checkRequired("groupValues", groupValues).map { it.toImmutable() }, - checkRequired("startingAt", startingAt), - endingBefore, + fun build(): UpdateCommit = + UpdateCommit( + checkRequired("id", id), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -19622,15 +23714,25 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): AddUsageFilter = apply { + fun validate(): UpdateCommit = apply { if (validated) { return@apply } - groupKey() - groupValues() - startingAt() - endingBefore() + id() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + invoiceSchedule().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } validated = true } @@ -19650,1873 +23752,1960 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupKey.asKnown().isPresent) 1 else 0) + - (groupValues.asKnown().getOrNull()?.size ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddUsageFilter && - groupKey == other.groupKey && - groupValues == other.groupValues && - startingAt == other.startingAt && - endingBefore == other.endingBefore && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupKey, - groupValues, - startingAt, - endingBefore, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddUsageFilter{groupKey=$groupKey, groupValues=$groupValues, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" - } - - class ArchiveCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + (if (id.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - @JsonCreator + class AccessSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ArchiveCommit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ArchiveCommit]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(archiveCommit: ArchiveCommit) = apply { - id = archiveCommit.id - additionalProperties = archiveCommit.additionalProperties.toMutableMap() - } + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun id(id: String) = id(JsonField.of(id)) + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + mutableMapOf(), + ) /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") /** - * Returns an immutable instance of [ArchiveCommit]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns the raw JSON value of [addScheduleItems]. * - * The following fields are required: - * ```java - * .id() - * ``` + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems + + /** + * Returns the raw JSON value of [removeScheduleItems]. * - * @throws IllegalStateException if any required field is unset. + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun build(): ArchiveCommit = - ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) - } + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = + removeScheduleItems - private var validated: Boolean = false + /** + * Returns the raw JSON value of [updateScheduleItems]. + * + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = + updateScheduleItems - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ArchiveCommit = apply { - if (validated) { - return@apply + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - id() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns a mutable builder for constructing an instance of + * [AccessSchedule]. + */ + @JvmStatic fun builder() = Builder() } - return other is ArchiveCommit && - id == other.id && - additionalProperties == other.additionalProperties - } + /** A builder for [AccessSchedule]. */ + class Builder internal constructor() { - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private var addScheduleItems: JsonField>? = + null + private var removeScheduleItems: + JsonField>? = + null + private var updateScheduleItems: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun hashCode(): Int = hashCode + @JvmSynthetic + internal fun from(accessSchedule: AccessSchedule) = apply { + addScheduleItems = + accessSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + accessSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + accessSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = + accessSchedule.additionalProperties.toMutableMap() + } - override fun toString() = - "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" - } + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) - class ArchiveCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = + apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems( + removeScheduleItems: JsonField> + ) = apply { + this.removeScheduleItems = + removeScheduleItems.map { it.toMutableList() } + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems( + updateScheduleItems: JsonField> + ) = apply { + this.updateScheduleItems = + updateScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of [ArchiveCredit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [ArchiveCredit]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(archiveCredit: ArchiveCredit) = apply { - id = archiveCredit.id - additionalProperties = archiveCredit.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [AccessSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessSchedule = + AccessSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun id(id: String) = id(JsonField.of(id)) + private var validated: Boolean = false /** - * Sets [Builder.id] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun id(id: JsonField) = apply { this.id = id } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): AccessSchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [ArchiveCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): ArchiveCredit = - ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) - } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) - private var validated: Boolean = false + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ArchiveCredit = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) - id() - validated = true - } + /** + * @throws MetronomeInvalidDataException if 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") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * RFC 3339 timestamp (exclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * RFC 3339 timestamp (inclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - return other is ArchiveCredit && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class ArchiveScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + amount = addScheduleItem.amount + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt + additionalProperties = + addScheduleItem.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun toBuilder() = Builder().from(this) + /** + * 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 } - companion object { + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns a mutable builder for constructing an instance of - * [ArchiveScheduledCharge]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** A builder for [ArchiveScheduledCharge]. */ - class Builder internal constructor() { + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - @JvmSynthetic - internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { - id = archiveScheduledCharge.id - additionalProperties = - archiveScheduledCharge.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [ArchiveScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ArchiveScheduledCharge = - ArchiveScheduledCharge( - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } + amount() + endingBefore() + startingAt() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ArchiveScheduledCharge = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - id() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is AddScheduleItem && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, endingBefore, startingAt, additionalProperties) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun toString() = + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } - return other is ArchiveScheduledCharge && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - override fun toString() = - "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun id(): String = id.getRequired("id") - class RemoveOverride - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun toBuilder() = Builder().from(this) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { - companion object { + private var id: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns a mutable builder for constructing an instance of [RemoveOverride]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() + } - /** A builder for [RemoveOverride]. */ - class Builder internal constructor() { + fun id(id: String) = id(JsonField.of(id)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - @JvmSynthetic - internal fun from(removeOverride: RemoveOverride) = apply { - id = removeOverride.id - additionalProperties = removeOverride.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false - /** - * Returns an immutable instance of [RemoveOverride]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveOverride = - RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + id() + validated = true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): RemoveOverride = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - id() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - return other is RemoveOverride && - id == other.id && - additionalProperties == other.additionalProperties - } + override fun hashCode(): Int = hashCode - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" + } - override fun hashCode(): Int = hashCode + class UpdateScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - class UpdateCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, - private val invoiceSchedule: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun id(): String = id.getRequired("id") - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("invoice_schedule") - @ExcludeMissing - invoiceSchedule: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - mutableMapOf(), - ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * RFC 3339 timestamp (exclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") + /** + * RFC 3339 timestamp (inclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): Optional = + startingAt.getOptional("starting_at") - /** - * Which products the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Which tags the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * 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 - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Optional configuration for commit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun invoiceSchedule(): Optional = - invoiceSchedule.getOptional("invoice_schedule") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + companion object { - /** - * If multiple commits are applicable, the one with the lower priority will apply - * first. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") + /** + * Returns a mutable builder for constructing an instance of + * [UpdateScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + /** A builder for [UpdateScheduleItem]. */ + class Builder internal constructor() { - /** - * If set, the commit's rate type was updated to the specified value. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + @JvmSynthetic + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt + additionalProperties = + updateScheduleItem.additionalProperties.toMutableMap() + } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + /** + * 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 } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Returns the raw JSON value of [invoiceSchedule]. - * - * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_schedule") - @ExcludeMissing - fun _invoiceSchedule(): JsonField = invoiceSchedule + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("priority") - @ExcludeMissing - fun _priority(): JsonField = priority + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + /** + * Returns an immutable instance of [UpdateScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + endingBefore, + startingAt, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + private var validated: Boolean = false - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): UpdateScheduleItem = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + id() + amount() + endingBefore() + startingAt() + validated = true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun toBuilder() = Builder().from(this) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a mutable builder for constructing an instance of [UpdateCommit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + return other is UpdateScheduleItem && + id == other.id && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** A builder for [UpdateCommit]. */ - class Builder internal constructor() { + private val hashCode: Int by lazy { + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) + } - private var id: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var invoiceSchedule: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun hashCode(): Int = hashCode - @JvmSynthetic - internal fun from(updateCommit: UpdateCommit) = apply { - id = updateCommit.id - accessSchedule = updateCommit.accessSchedule - applicableProductIds = - updateCommit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCommit.applicableProductTags.map { it.toMutableList() } - description = updateCommit.description - hierarchyConfiguration = updateCommit.hierarchyConfiguration - invoiceSchedule = updateCommit.invoiceSchedule - name = updateCommit.name - netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId - priority = updateCommit.priority - productId = updateCommit.productId - rateType = updateCommit.rateType - rolloverFraction = updateCommit.rolloverFraction - specifiers = updateCommit.specifiers.map { it.toMutableList() } - additionalProperties = updateCommit.additionalProperties.toMutableMap() + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + return other is AccessSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.accessSchedule] with a well-typed - * [AccessSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) } - /** - * Which products the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to - * all products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + override fun toString() = + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = - apply { - this.applicableProductIds = - applicableProductIds.map { it.toMutableList() } - } + class InvoiceSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + mutableMapOf(), + ) /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") /** - * Which tags the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to - * all products. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * Returns the raw JSON value of [addScheduleItems]. * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: JsonField>) = - apply { - this.applicableProductTags = - applicableProductTags.map { it.toMutableList() } - } + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems /** - * Adds a single [String] to [applicableProductTags]. + * Returns the raw JSON value of [removeScheduleItems]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } - } - - fun description(description: String) = description(JsonField.of(description)) + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = + removeScheduleItems /** - * Sets [Builder.description] to an arbitrary JSON value. + * Returns the raw JSON value of [updateScheduleItems]. * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun description(description: JsonField) = apply { - this.description = description + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = + updateScheduleItems + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** Optional configuration for commit hierarchy access control */ - fun hierarchyConfiguration( - hierarchyConfiguration: CommitHierarchyConfiguration - ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + fun toBuilder() = Builder().from(this) - fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = - invoiceSchedule(JsonField.of(invoiceSchedule)) + companion object { - /** - * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceSchedule] with a well-typed - * [InvoiceSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoiceSchedule(invoiceSchedule: JsonField) = apply { - this.invoiceSchedule = invoiceSchedule + /** + * Returns a mutable builder for constructing an instance of + * [InvoiceSchedule]. + */ + @JvmStatic fun builder() = Builder() } - fun name(name: String) = name(JsonField.of(name)) + /** A builder for [InvoiceSchedule]. */ + class Builder internal constructor() { - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + private var addScheduleItems: JsonField>? = + null + private var removeScheduleItems: + JsonField>? = + null + private var updateScheduleItems: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + @JvmSynthetic + internal fun from(invoiceSchedule: InvoiceSchedule) = apply { + addScheduleItems = + invoiceSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + invoiceSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = + invoiceSchedule.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = + apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } - /** - * If multiple commits are applicable, the one with the lower priority will - * apply first. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems( + removeScheduleItems: JsonField> + ) = apply { + this.removeScheduleItems = + removeScheduleItems.map { it.toMutableList() } + } - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } - fun productId(productId: String) = productId(JsonField.of(productId)) + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) + + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems( + updateScheduleItems: JsonField> + ) = apply { + this.updateScheduleItems = + updateScheduleItems.map { it.toMutableList() } + } - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productId(productId: JsonField) = apply { - this.productId = productId - } + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } - /** If set, the commit's rate type was updated to the specified value. */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for [Builder.rolloverFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [Builder.rolloverFraction] with - * `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction + /** + * Returns an immutable instance of [InvoiceSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceSchedule = + InvoiceSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at least - * one of the specifiers to contribute to a commit's or credit's drawdown. This - * field cannot be used together with `applicable_product_ids` or - * `applicable_product_tags`. Instead, to target usage by product or product - * tag, pass those values in the body of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) - - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } - - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): InvoiceSchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [UpdateCommit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): UpdateCommit = - UpdateCommit( - checkRequired("id", id), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) - private var validated: Boolean = false + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateCommit = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) - id() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - invoiceSchedule().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - validated = true - } + /** + * @throws MetronomeInvalidDataException if 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") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - class AccessSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - @JsonCreator - private constructor( - @JsonProperty("add_schedule_items") + /** + * 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 - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") + fun _timestamp(): JsonField = timestamp + + /** + * 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 - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - mutableMapOf(), - ) + fun _quantity(): JsonField = quantity - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [removeScheduleItems]. - * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = - removeScheduleItems + companion object { - /** - * Returns the raw JSON value of [updateScheduleItems]. - * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("update_schedule_items") - @ExcludeMissing - fun _updateScheduleItems(): JsonField> = - updateScheduleItems + /** + * Returns a mutable builder for constructing an instance of + * [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun toBuilder() = Builder().from(this) + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + timestamp = addScheduleItem.timestamp + amount = addScheduleItem.amount + quantity = addScheduleItem.quantity + unitPrice = addScheduleItem.unitPrice + additionalProperties = + addScheduleItem.additionalProperties.toMutableMap() + } + + 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 + } + + 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 } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [AccessSchedule]. - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [AccessSchedule]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var addScheduleItems: JsonField>? = - null - private var removeScheduleItems: - JsonField>? = - null - private var updateScheduleItems: - JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = - accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = - accessSchedule.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + private var validated: Boolean = false /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addScheduleItems(addScheduleItems: JsonField>) = - apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } + + timestamp() + amount() + quantity() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Used for best match union deserialization. */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) - } + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties } - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + private val hashCode: Int by lazy { + Objects.hash( + timestamp, + amount, + quantity, + unitPrice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - fun removeScheduleItems( - removeScheduleItems: JsonField> - ) = apply { - this.removeScheduleItems = - removeScheduleItems.map { it.toMutableList() } - } + fun id(): String = id.getRequired("id") /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * Returns the raw JSON value of [id]. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * Unlike [id], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) } - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + private var validated: Boolean = false /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun updateScheduleItems( - updateScheduleItems: JsonField> - ) = apply { - this.updateScheduleItems = - updateScheduleItems.map { it.toMutableList() } - } - - /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + id() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AccessSchedule]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AccessSchedule = apply { - if (validated) { - return@apply + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties } - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" + } - class AddScheduleItem + class UpdateScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val id: JsonField, private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val quantity: JsonField, + private val timestamp: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + quantity: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") + fun id(): String = id.getRequired("id") /** - * RFC 3339 timestamp (exclusive) - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") + fun amount(): Optional = amount.getOptional("amount") /** - * RFC 3339 timestamp (inclusive) - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): Optional = + timestamp.getOptional("timestamp") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [amount]. @@ -21529,24 +25718,34 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [quantity]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * Unlike [quantity], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [timestamp]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an + * Unlike [timestamp], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("starting_at") + @JsonProperty("timestamp") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _timestamp(): JsonField = timestamp + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -21564,36 +25763,49 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [AddScheduleItem]. + * [UpdateScheduleItem]. * * The following fields are required: * ```java - * .amount() - * .endingBefore() - * .startingAt() + * .id() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddScheduleItem]. */ + /** A builder for [UpdateScheduleItem]. */ class Builder internal constructor() { - private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + quantity = updateScheduleItem.quantity + timestamp = updateScheduleItem.timestamp + unitPrice = updateScheduleItem.unitPrice additionalProperties = - addScheduleItem.additionalProperties.toMutableMap() + updateScheduleItem.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -21605,34 +25817,44 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun timestamp(timestamp: OffsetDateTime) = + timestamp(JsonField.of(timestamp)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.timestamp] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed + * 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 startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = @@ -21641,623 +25863,1120 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + quantity, + timestamp, + unitPrice, + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): UpdateScheduleItem = apply { + if (validated) { + return@apply + } + + id() + amount() + quantity() + timestamp() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateScheduleItem && + id == other.id && + amount == other.amount && + quantity == other.quantity && + timestamp == other.timestamp && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + quantity, + timestamp, + unitPrice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } + + /** If set, the commit's rate type was updated to the specified value. */ + class RateType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false - /** - * Returns an immutable instance of [AddScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddScheduleItem = - AddScheduleItem( - checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply } - private var validated: Boolean = false + known() + validated = true + } - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AddScheduleItem = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - amount() - endingBefore() - startingAt() - validated = true + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is RateType && value == other.value + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + override fun hashCode() = value.hashCode() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun toString() = value.toString() + } - return other is AddScheduleItem && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) - } + return other is UpdateCommit && + id == other.id && + accessSchedule == other.accessSchedule && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceSchedule == other.invoiceSchedule && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + priority == other.priority && + productId == other.productId && + rateType == other.rateType && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + additionalProperties == other.additionalProperties + } - override fun hashCode(): Int = hashCode + private val hashCode: Int by lazy { + Objects.hash( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + additionalProperties, + ) + } - override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + override fun hashCode(): Int = hashCode - class RemoveScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = + "UpdateCommit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" + } - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + class UpdateCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun id(): String = id.getRequired("id") + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") + @ExcludeMissing + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + mutableMapOf(), + ) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Which products the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - fun toBuilder() = Builder().from(this) + /** + * Which tags the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** - * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Optional configuration for credit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") - /** A builder for [RemoveScheduleItem]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - private var id: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id - additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() - } + /** + * If multiple credits are applicable, the one with the lower priority will apply + * first. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - fun id(id: String) = id(JsonField.of(id)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * If set, the credit's rate type was updated to the specified value. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** - * Returns an immutable instance of [RemoveScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - private var validated: Boolean = false + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): RemoveScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration - id() - validated = true - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") + @ExcludeMissing + fun _priority(): JsonField = priority - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId - return other is RemoveScheduleItem && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun id(): String = id.getRequired("id") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + /** + * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + /** A builder for [UpdateCredit]. */ + class Builder internal constructor() { - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = - startingAt.getOptional("starting_at") + private var id: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JvmSynthetic + internal fun from(updateCredit: UpdateCredit) = apply { + id = updateCredit.id + accessSchedule = updateCredit.accessSchedule + applicableProductIds = + updateCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCredit.applicableProductTags.map { it.toMutableList() } + description = updateCredit.description + hierarchyConfiguration = updateCredit.hierarchyConfiguration + name = updateCredit.name + netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId + priority = updateCredit.priority + productId = updateCredit.productId + rateType = updateCredit.rateType + rolloverFraction = updateCredit.rolloverFraction + specifiers = updateCredit.specifiers.map { it.toMutableList() } + additionalProperties = updateCredit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * 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 + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + /** + * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.accessSchedule] with a well-typed + * [AccessSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule + } - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Which products the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to + * all products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = + apply { + this.applicableProductIds = + applicableProductIds.map { it.toMutableList() } } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - fun toBuilder() = Builder().from(this) + /** + * Which tags the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to + * all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - companion object { + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - /** - * Returns a mutable builder for constructing an instance of - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = + apply { + this.applicableProductTags = + applicableProductTags.map { it.toMutableList() } } - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun description(description: String) = description(JsonField.of(description)) - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - fun id(id: String) = id(JsonField.of(id)) + /** Optional configuration for credit hierarchy access control */ + fun hierarchyConfiguration( + hierarchyConfiguration: CommitHierarchyConfiguration + ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - fun amount(amount: Double) = amount(JsonField.of(amount)) + fun name(name: String) = name(JsonField.of(name)) - /** - * 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 } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * If multiple credits are applicable, the one with the lower priority will + * apply first. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun productId(productId: String) = productId(JsonField.of(productId)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productId(productId: JsonField) = apply { + this.productId = productId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** If set, the credit's rate type was updated to the specified value. */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - private var validated: Boolean = false + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * Alias for calling [Builder.rolloverFraction] with + * `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at least + * one of the specifiers to contribute to a commit's or credit's drawdown. This + * field cannot be used together with `applicable_product_ids` or + * `applicable_product_tags`. Instead, to target usage by product or product + * tag, pass those values in the body of `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) - } + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } - override fun hashCode(): Int = hashCode + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateCredit = + UpdateCredit( + checkRequired("id", id), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): UpdateCredit = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + id() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + validated = true } - class InvoiceSchedule + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class AccessSchedule @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val addScheduleItems: JsonField>, @@ -22353,12 +27072,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InvoiceSchedule]. + * [AccessSchedule]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoiceSchedule]. */ + /** A builder for [AccessSchedule]. */ class Builder internal constructor() { private var addScheduleItems: JsonField>? = @@ -22373,15 +27092,15 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(invoiceSchedule: InvoiceSchedule) = apply { + internal fun from(accessSchedule: AccessSchedule) = apply { addScheduleItems = - invoiceSchedule.addScheduleItems.map { it.toMutableList() } + accessSchedule.addScheduleItems.map { it.toMutableList() } removeScheduleItems = - invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + accessSchedule.removeScheduleItems.map { it.toMutableList() } updateScheduleItems = - invoiceSchedule.updateScheduleItems.map { it.toMutableList() } + accessSchedule.updateScheduleItems.map { it.toMutableList() } additionalProperties = - invoiceSchedule.additionalProperties.toMutableMap() + accessSchedule.additionalProperties.toMutableMap() } fun addScheduleItems(addScheduleItems: List) = @@ -22495,12 +27214,12 @@ private constructor( } /** - * Returns an immutable instance of [InvoiceSchedule]. + * Returns an immutable instance of [AccessSchedule]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): InvoiceSchedule = - InvoiceSchedule( + fun build(): AccessSchedule = + AccessSchedule( (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, @@ -22520,7 +27239,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): InvoiceSchedule = apply { + fun validate(): AccessSchedule = apply { if (validated) { return@apply } @@ -22559,63 +27278,50 @@ private constructor( class AddScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val timestamp: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun amount(): Double = amount.getRequired("amount") /** + * RFC 3339 timestamp (exclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") /** - * Returns the raw JSON value of [timestamp]. + * RFC 3339 timestamp (inclusive) * - * Unlike [timestamp], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - @JsonProperty("timestamp") - @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") /** * Returns the raw JSON value of [amount]. @@ -22628,24 +27334,24 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - fun _quantity(): JsonField = quantity + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * Unlike [startingAt], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22667,7 +27373,9 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -22676,37 +27384,21 @@ private constructor( /** A builder for [AddScheduleItem]. */ class Builder internal constructor() { - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addScheduleItem: AddScheduleItem) = apply { - timestamp = addScheduleItem.timestamp amount = addScheduleItem.amount - quantity = addScheduleItem.quantity - unitPrice = addScheduleItem.unitPrice + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt additionalProperties = addScheduleItem.additionalProperties.toMutableMap() } - 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 - } - fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -22718,30 +27410,34 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed - * [Double] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = @@ -22774,17 +27470,18 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AddScheduleItem = AddScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), additionalProperties.toMutableMap(), ) } @@ -22806,10 +27503,9 @@ private constructor( return@apply } - timestamp() amount() - quantity() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -22829,10 +27525,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -22840,27 +27535,20 @@ private constructor( } return other is AddScheduleItem && - timestamp == other.timestamp && amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - timestamp, - amount, - quantity, - unitPrice, - additionalProperties, - ) + Objects.hash(amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } class RemoveScheduleItem @@ -23046,9 +27734,8 @@ private constructor( private constructor( private val id: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val timestamp: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -23060,16 +27747,13 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonProperty("ending_before") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected @@ -23085,23 +27769,22 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** + * RFC 3339 timestamp (exclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun timestamp(): Optional = - timestamp.getOptional("timestamp") + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** + * RFC 3339 timestamp (inclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun startingAt(): Optional = + startingAt.getOptional("starting_at") /** * Returns the raw JSON value of [id]. @@ -23122,34 +27805,24 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [timestamp]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [timestamp], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("timestamp") + @JsonProperty("ending_before") @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * Unlike [startingAt], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23182,9 +27855,8 @@ private constructor( private var id: JsonField? = null private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var timestamp: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -23192,9 +27864,8 @@ private constructor( internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { id = updateScheduleItem.id amount = updateScheduleItem.amount - quantity = updateScheduleItem.quantity - timestamp = updateScheduleItem.timestamp - unitPrice = updateScheduleItem.unitPrice + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt additionalProperties = updateScheduleItem.additionalProperties.toMutableMap() } @@ -23221,44 +27892,34 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } - - fun timestamp(timestamp: OffsetDateTime) = - timestamp(JsonField.of(timestamp)) + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.timestamp] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.timestamp] with a well-typed + * You should usually call [Builder.endingBefore] 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 + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed - * [Double] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = @@ -23300,9 +27961,8 @@ private constructor( UpdateScheduleItem( checkRequired("id", id), amount, - quantity, - timestamp, - unitPrice, + endingBefore, + startingAt, additionalProperties.toMutableMap(), ) } @@ -23326,9 +27986,8 @@ private constructor( id() amount() - quantity() - timestamp() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -23350,9 +28009,8 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -23362,27 +28020,19 @@ private constructor( return other is UpdateScheduleItem && id == other.id && amount == other.amount && - quantity == other.quantity && - timestamp == other.timestamp && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - id, - amount, - quantity, - timestamp, - unitPrice, - additionalProperties, - ) + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -23390,7 +28040,7 @@ private constructor( return true } - return other is InvoiceSchedule && + return other is AccessSchedule && addScheduleItems == other.addScheduleItems && removeScheduleItems == other.removeScheduleItems && updateScheduleItems == other.updateScheduleItems && @@ -23409,10 +28059,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" } - /** If set, the commit's rate type was updated to the specified value. */ + /** If set, the credit's rate type was updated to the specified value. */ class RateType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23430,17 +28080,17 @@ private constructor( companion object { - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - @JvmField val LIST_RATE = of("LIST_RATE") + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) } /** An enum containing [RateType]'s known values. */ enum class Known { - COMMIT_RATE, LIST_RATE, + COMMIT_RATE, } /** @@ -23454,8 +28104,8 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - COMMIT_RATE, LIST_RATE, + COMMIT_RATE, /** * An enum member indicating that [RateType] was instantiated with an * unknown value. @@ -23472,8 +28122,8 @@ private constructor( */ fun value(): Value = when (this) { - COMMIT_RATE -> Value.COMMIT_RATE LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE else -> Value._UNKNOWN } @@ -23488,8 +28138,8 @@ private constructor( */ fun known(): Known = when (this) { - COMMIT_RATE -> Known.COMMIT_RATE LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE else -> throw MetronomeInvalidDataException("Unknown RateType: $value") } @@ -23563,14 +28213,13 @@ private constructor( return true } - return other is UpdateCommit && + return other is UpdateCredit && id == other.id && accessSchedule == other.accessSchedule && applicableProductIds == other.applicableProductIds && applicableProductTags == other.applicableProductTags && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && - invoiceSchedule == other.invoiceSchedule && name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && priority == other.priority && @@ -23589,7 +28238,6 @@ private constructor( applicableProductTags, description, hierarchyConfiguration, - invoiceSchedule, name, netsuiteSalesOrderId, priority, @@ -23604,135 +28252,52 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateCommit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" + "UpdateCredit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" } - class UpdateCredit + class UpdateDiscount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, + private val customFields: JsonField, private val name: JsonField, private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, + private val schedule: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") + @JsonProperty("custom_fields") @ExcludeMissing - hierarchyConfiguration: JsonField = - JsonMissing.of(), + customFields: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("netsuite_sales_order_id") @ExcludeMissing netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") + @JsonProperty("schedule") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - mutableMapOf(), - ) + schedule: JsonField = JsonMissing.of(), + ) : this(id, customFields, name, netsuiteSalesOrderId, schedule, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") - - /** - * Which products the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") - - /** - * Which tags the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + fun id(): String = id.getRequired("id") /** - * Optional configuration for credit hierarchy access control + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + fun customFields(): Optional = + customFields.getOptional("custom_fields") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type @@ -23748,48 +28313,12 @@ private constructor( netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") /** - * If multiple credits are applicable, the one with the lower priority will apply - * first. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") - - /** - * If set, the credit's rate type was updated to the specified value. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") - - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. + * Must provide either schedule_items or recurring_schedule. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + fun schedule(): Optional = schedule.getOptional("schedule") /** * Returns the raw JSON value of [id]. @@ -23799,55 +28328,14 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule - - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds - - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags - - /** - * Returns the raw JSON value of [description]. + * Returns the raw JSON value of [customFields]. * - * Unlike [description], this method doesn't throw if the JSON field has an + * Unlike [customFields], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("hierarchy_configuration") + @JsonProperty("custom_fields") @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + fun _customFields(): JsonField = customFields /** * Returns the raw JSON value of [name]. @@ -23868,1121 +28356,1567 @@ private constructor( fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId /** - * Returns the raw JSON value of [priority]. + * Returns the raw JSON value of [schedule]. * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("priority") + @JsonProperty("schedule") @ExcludeMissing - fun _priority(): JsonField = priority + fun _schedule(): JsonField = schedule + + @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 [UpdateDiscount]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateDiscount]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customFields: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateDiscount: UpdateDiscount) = apply { + id = updateDiscount.id + customFields = updateDiscount.customFields + name = updateDiscount.name + netsuiteSalesOrderId = updateDiscount.netsuiteSalesOrderId + schedule = updateDiscount.schedule + additionalProperties = updateDiscount.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = + customFields(JsonField.of(customFields)) + + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed + * [CustomFields] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** Must provide either schedule_items or recurring_schedule. */ + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateDiscount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateDiscount = + UpdateDiscount( + checkRequired("id", id), + customFields, + name, + netsuiteSalesOrderId, + schedule, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId + private var validated: Boolean = false /** - * Returns the raw JSON value of [rateType]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType - - /** - * Returns the raw JSON value of [rolloverFraction]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + fun validate(): UpdateDiscount = apply { + if (validated) { + return@apply + } + + id() + customFields().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + schedule().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [specifiers]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [specifiers], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun toBuilder() = Builder().from(this) + fun toBuilder() = Builder().from(this) - companion object { + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomFields]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * The following fields are required: - * ```java - * .id() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - @JvmStatic fun builder() = Builder() - } + fun validate(): CustomFields = apply { + if (validated) { + return@apply + } - /** A builder for [UpdateCredit]. */ - class Builder internal constructor() { + validated = true + } - private var id: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ @JvmSynthetic - internal fun from(updateCredit: UpdateCredit) = apply { - id = updateCredit.id - accessSchedule = updateCredit.accessSchedule - applicableProductIds = - updateCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCredit.applicableProductTags.map { it.toMutableList() } - description = updateCredit.description - hierarchyConfiguration = updateCredit.hierarchyConfiguration - name = updateCredit.name - netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId - priority = updateCredit.priority - productId = updateCredit.productId - rateType = updateCredit.rateType - rolloverFraction = updateCredit.rolloverFraction - specifiers = updateCredit.specifiers.map { it.toMutableList() } - additionalProperties = updateCredit.additionalProperties.toMutableMap() + 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 CustomFields && + additionalProperties == other.additionalProperties } - fun id(id: String) = id(JsonField.of(id)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFields{additionalProperties=$additionalProperties}" + } + + /** Must provide either schedule_items or recurring_schedule. */ + class Schedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val doNotInvoice: JsonField, + private val recurringSchedule: JsonField, + private val scheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("do_not_invoice") + @ExcludeMissing + doNotInvoice: JsonField = JsonMissing.of(), + @JsonProperty("recurring_schedule") + @ExcludeMissing + recurringSchedule: JsonField = JsonMissing.of(), + @JsonProperty("schedule_items") + @ExcludeMissing + scheduleItems: JsonField> = JsonMissing.of(), + ) : this( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + mutableMapOf(), + ) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Defaults to USD (cents) if not passed. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } - - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + fun creditTypeId(): Optional = + creditTypeId.getOptional("credit_type_id") /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * This field is only applicable to commit invoice schedules. If true, this + * schedule will not generate an invoice. * - * You should usually call [Builder.accessSchedule] with a well-typed - * [AccessSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule - } - - /** - * Which products the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to - * all products. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + fun doNotInvoice(): Optional = + doNotInvoice.getOptional("do_not_invoice") /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. + * Enter the unit price and quantity for the charge or instead only send the + * amount. If amount is sent, the unit price is assumed to be the amount and + * quantity is inferred to be 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + fun recurringSchedule(): Optional = + recurringSchedule.getOptional("recurring_schedule") /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * Either provide amount or provide both unit_price and quantity. * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: JsonField>) = - apply { - this.applicableProductIds = - applicableProductIds.map { it.toMutableList() } - } + fun scheduleItems(): Optional> = + scheduleItems.getOptional("schedule_items") /** - * Adds a single [String] to [applicableProductIds]. + * Returns the raw JSON value of [creditTypeId]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId /** - * Which tags the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to - * all products. + * Returns the raw JSON value of [doNotInvoice]. + * + * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + @JsonProperty("do_not_invoice") + @ExcludeMissing + fun _doNotInvoice(): JsonField = doNotInvoice /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. + * Returns the raw JSON value of [recurringSchedule]. + * + * Unlike [recurringSchedule], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + @JsonProperty("recurring_schedule") + @ExcludeMissing + fun _recurringSchedule(): JsonField = recurringSchedule /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * Returns the raw JSON value of [scheduleItems]. * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Unlike [scheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: JsonField>) = - apply { - this.applicableProductTags = - applicableProductTags.map { it.toMutableList() } + @JsonProperty("schedule_items") + @ExcludeMissing + fun _scheduleItems(): JsonField> = scheduleItems + + @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 [Schedule]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField = JsonMissing.of() + private var doNotInvoice: JsonField = JsonMissing.of() + private var recurringSchedule: JsonField = + JsonMissing.of() + private var scheduleItems: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + creditTypeId = schedule.creditTypeId + doNotInvoice = schedule.doNotInvoice + recurringSchedule = schedule.recurringSchedule + scheduleItems = schedule.scheduleItems.map { it.toMutableList() } + additionalProperties = schedule.additionalProperties.toMutableMap() } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + /** Defaults to USD (cents) if not passed. */ + fun creditTypeId(creditTypeId: String) = + creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + /** + * This field is only applicable to commit invoice schedules. If true, this + * schedule will not generate an invoice. + */ + fun doNotInvoice(doNotInvoice: Boolean) = + doNotInvoice(JsonField.of(doNotInvoice)) + + /** + * Sets [Builder.doNotInvoice] to an arbitrary JSON value. + * + * You should usually call [Builder.doNotInvoice] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun doNotInvoice(doNotInvoice: JsonField) = apply { + this.doNotInvoice = doNotInvoice + } + + /** + * Enter the unit price and quantity for the charge or instead only send the + * amount. If amount is sent, the unit price is assumed to be the amount and + * quantity is inferred to be 1. + */ + fun recurringSchedule(recurringSchedule: RecurringSchedule) = + recurringSchedule(JsonField.of(recurringSchedule)) + + /** + * Sets [Builder.recurringSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.recurringSchedule] with a well-typed + * [RecurringSchedule] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun recurringSchedule(recurringSchedule: JsonField) = + apply { + this.recurringSchedule = recurringSchedule } - } - fun description(description: String) = description(JsonField.of(description)) + /** Either provide amount or provide both unit_price and quantity. */ + fun scheduleItems(scheduleItems: List) = + scheduleItems(JsonField.of(scheduleItems)) + + /** + * Sets [Builder.scheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scheduleItems(scheduleItems: JsonField>) = apply { + this.scheduleItems = scheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleItem] to [scheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScheduleItem(scheduleItem: ScheduleItem) = apply { + scheduleItems = + (scheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleItems", it).add(scheduleItem) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Schedule = + Schedule( + creditTypeId, + doNotInvoice, + recurringSchedule, + (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - /** Optional configuration for credit hierarchy access control */ - fun hierarchyConfiguration( - hierarchyConfiguration: CommitHierarchyConfiguration - ) = hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + private var validated: Boolean = false /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun name(name: JsonField) = apply { this.name = name } + fun validate(): Schedule = apply { + if (validated) { + return@apply + } - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + creditTypeId() + doNotInvoice() + recurringSchedule().ifPresent { it.validate() } + scheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (doNotInvoice.asKnown().isPresent) 1 else 0) + + (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) /** - * If multiple credits are applicable, the one with the lower priority will - * apply first. + * Enter the unit price and quantity for the charge or instead only send the + * amount. If amount is sent, the unit price is assumed to be the amount and + * quantity is inferred to be 1. */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + class RecurringSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amountDistribution: JsonField, + private val endingBefore: JsonField, + private val frequency: JsonField, + private val startingAt: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) + @JsonCreator + private constructor( + @JsonProperty("amount_distribution") + @ExcludeMissing + amountDistribution: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + mutableMapOf(), + ) - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun amountDistribution(): AmountDistribution = + amountDistribution.getRequired("amount_distribution") - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + /** + * RFC 3339 timestamp (exclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun endingBefore(): OffsetDateTime = + endingBefore.getRequired("ending_before") - fun productId(productId: String) = productId(JsonField.of(productId)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun frequency(): Frequency = frequency.getRequired("frequency") - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productId(productId: JsonField) = apply { - this.productId = productId - } + /** + * RFC 3339 timestamp (inclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** If set, the credit's rate type was updated to the specified value. */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the amount + * and quantity is inferred to be 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + /** + * Quantity for the charge. Will be multiplied by unit_price to determine + * the amount and must be specified with unit_price. If specified amount + * cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Unit price for the charge. Will be multiplied by quantity to determine + * the amount and must be specified with quantity. If specified amount + * cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [amountDistribution]. + * + * Unlike [amountDistribution], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("amount_distribution") + @ExcludeMissing + fun _amountDistribution(): JsonField = + amountDistribution - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * Alias for [Builder.rolloverFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - /** - * Alias for calling [Builder.rolloverFraction] with - * `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + /** + * 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 - /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at least - * one of the specifiers to contribute to a commit's or credit's drawdown. This - * field cannot be used together with `applicable_product_ids` or - * `applicable_product_tags`. Instead, to target usage by product or product - * tag, pass those values in the body of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of + * [RecurringSchedule]. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [RecurringSchedule]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [UpdateCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateCredit = - UpdateCredit( - checkRequired("id", id), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + private var amountDistribution: JsonField? = null + private var endingBefore: JsonField? = null + private var frequency: JsonField? = null + private var startingAt: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - private var validated: Boolean = false + @JvmSynthetic + internal fun from(recurringSchedule: RecurringSchedule) = apply { + amountDistribution = recurringSchedule.amountDistribution + endingBefore = recurringSchedule.endingBefore + frequency = recurringSchedule.frequency + startingAt = recurringSchedule.startingAt + amount = recurringSchedule.amount + quantity = recurringSchedule.quantity + unitPrice = recurringSchedule.unitPrice + additionalProperties = + recurringSchedule.additionalProperties.toMutableMap() + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateCredit = apply { - if (validated) { - return@apply - } + fun amountDistribution(amountDistribution: AmountDistribution) = + amountDistribution(JsonField.of(amountDistribution)) - id() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - validated = true - } + /** + * Sets [Builder.amountDistribution] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDistribution] with a + * well-typed [AmountDistribution] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountDistribution( + amountDistribution: JsonField + ) = apply { this.amountDistribution = amountDistribution } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** RFC 3339 timestamp (exclusive). */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - class AccessSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) - @JsonCreator - private constructor( - @JsonProperty("add_schedule_items") - @ExcludeMissing - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") - @ExcludeMissing - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") - @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - mutableMapOf(), - ) + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed + * [Frequency] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + /** RFC 3339 timestamp (inclusive). */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") + /** + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the + * amount and quantity is inferred to be 1. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + /** + * 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 } - /** - * Returns the raw JSON value of [removeScheduleItems]. - * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = - removeScheduleItems + /** + * Quantity for the charge. Will be multiplied by unit_price to + * determine the amount and must be specified with unit_price. If + * specified amount cannot be provided. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - /** - * Returns the raw JSON value of [updateScheduleItems]. - * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("update_schedule_items") - @ExcludeMissing - fun _updateScheduleItems(): JsonField> = - updateScheduleItems + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Unit price for the charge. Will be multiplied by quantity to + * determine the amount and must be specified with quantity. If + * specified amount cannot be provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [AccessSchedule]. - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [AccessSchedule]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var addScheduleItems: JsonField>? = - null - private var removeScheduleItems: - JsonField>? = - null - private var updateScheduleItems: - JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = - accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = - accessSchedule.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [RecurringSchedule]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringSchedule = + RecurringSchedule( + checkRequired("amountDistribution", amountDistribution), + checkRequired("endingBefore", endingBefore), + checkRequired("frequency", frequency), + checkRequired("startingAt", startingAt), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + private var validated: Boolean = false /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addScheduleItems(addScheduleItems: JsonField>) = - apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + fun validate(): RecurringSchedule = apply { + if (validated) { + return@apply } - /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) - } + amountDistribution().validate() + endingBefore() + frequency().validate() + startingAt() + amount() + quantity() + unitPrice() + validated = true } - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun removeScheduleItems( - removeScheduleItems: JsonField> - ) = apply { - this.removeScheduleItems = - removeScheduleItems.map { it.toMutableList() } - } + @JvmSynthetic + internal fun validity(): Int = + (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (frequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) - } - } + class AmountDistribution + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun updateScheduleItems( - updateScheduleItems: JsonField> - ) = apply { - this.updateScheduleItems = - updateScheduleItems.map { it.toMutableList() } - } + companion object { - /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } - } + @JvmField val DIVIDED = of("DIVIDED") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") + + @JvmField val EACH = of("EACH") + + @JvmStatic + fun of(value: String) = AmountDistribution(JsonField.of(value)) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [AmountDistribution]'s known values. */ + enum class Known { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * An enum containing [AmountDistribution]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AmountDistribution] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + /** + * An enum member indicating that [AmountDistribution] was + * instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDED -> Value.DIVIDED + DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED + EACH -> Value.EACH + else -> Value._UNKNOWN + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DIVIDED -> Known.DIVIDED + DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED + EACH -> Known.EACH + else -> + throw MetronomeInvalidDataException( + "Unknown AmountDistribution: $value" + ) + } - /** - * Returns an immutable instance of [AccessSchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): AmountDistribution = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AccessSchedule = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is AmountDistribution && value == other.value + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + override fun hashCode() = value.hashCode() - class AddScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun toString() = value.toString() + } + class Frequency @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if 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") + private constructor(private val value: JsonField) : Enum { - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + companion object { - /** - * 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 + @JvmField val MONTHLY = of("MONTHLY") - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JvmField val QUARTERLY = of("QUARTERLY") - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val ANNUAL = of("ANNUAL") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val WEEKLY = of("WEEKLY") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) + } - companion object { + /** An enum containing [Frequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + } /** - * Returns a mutable builder for constructing an instance of - * [AddScheduleItem]. + * An enum containing [Frequency]'s known values, as well as an + * [_UNKNOWN] member. * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` + * An instance of [Frequency] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddScheduleItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt - additionalProperties = - addScheduleItem.additionalProperties.toMutableMap() + enum class Value { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [Frequency] was instantiated with + * an unknown value. + */ + _UNKNOWN, } - fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Sets [Builder.amount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. * - * You should usually call [Builder.amount] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. */ - fun amount(amount: JsonField) = apply { this.amount = amount } + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException( + "Unknown Frequency: $value" + ) + } /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + private var validated: Boolean = false /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): Frequency = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` + * Returns a score indicating how many valid values are contained in + * this object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddScheduleItem = - AddScheduleItem( - checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AddScheduleItem = apply { - if (validated) { - return@apply + return other is Frequency && value == other.value } - amount() - endingBefore() - startingAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddScheduleItem && - amount == other.amount && + return other is RecurringSchedule && + amountDistribution == other.amountDistribution && endingBefore == other.endingBefore && + frequency == other.frequency && startingAt == other.startingAt && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) + Objects.hash( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class RemoveScheduleItem + class ScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") + @JsonProperty("timestamp") @ExcludeMissing - id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) /** + * timestamp of the scheduled event + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun id(): String = id.getRequired("id") + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") /** - * Returns the raw JSON value of [id]. + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the amount + * and quantity is inferred to be 1. * - * Unlike [id], this method doesn't throw if the JSON field has an + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Quantity for the charge. Will be multiplied by unit_price to determine + * the amount and must be specified with unit_price. If specified amount + * cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Unit price for the charge. Will be multiplied by quantity to determine + * the amount and must be specified with quantity. If specified amount + * cannot be provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * 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 [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 [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -25000,40 +29934,102 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. + * [ScheduleItem]. * * The following fields are required: * ```java - * .id() + * .timestamp() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemoveScheduleItem]. */ + /** A builder for [ScheduleItem]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id + internal fun from(scheduleItem: ScheduleItem) = apply { + timestamp = scheduleItem.timestamp + amount = scheduleItem.amount + quantity = scheduleItem.quantity + unitPrice = scheduleItem.unitPrice additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() + scheduleItem.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + /** timestamp of the scheduled event */ + fun timestamp(timestamp: OffsetDateTime) = + timestamp(JsonField.of(timestamp)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.timestamp] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an + * 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 + } + + /** + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the + * amount and quantity is inferred to be 1. + */ + 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 id(id: JsonField) = apply { this.id = id } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * Quantity for the charge. Will be multiplied by unit_price to + * determine the amount and must be specified with unit_price. If + * specified amount cannot be provided. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } + + /** + * Unit price for the charge. Will be multiplied by quantity to + * determine the amount and must be specified with quantity. If + * specified amount cannot be provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } fun additionalProperties(additionalProperties: Map) = apply { @@ -25058,21 +30054,24 @@ private constructor( } /** - * Returns an immutable instance of [RemoveScheduleItem]. + * Returns an immutable instance of [ScheduleItem]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .id() + * .timestamp() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), + fun build(): ScheduleItem = + ScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, additionalProperties.toMutableMap(), ) } @@ -25089,12 +30088,15 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): RemoveScheduleItem = apply { + fun validate(): ScheduleItem = apply { if (validated) { return@apply } - id() + timestamp() + amount() + quantity() + unitPrice() validated = true } @@ -25113,893 +30115,1069 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is RemoveScheduleItem && - id == other.id && + return other is ScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + timestamp, + amount, + quantity, + unitPrice, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } - - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = - startingAt.getOptional("starting_at") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [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 [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt - - @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 - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() + "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + return other is Schedule && + creditTypeId == other.creditTypeId && + doNotInvoice == other.doNotInvoice && + recurringSchedule == other.recurringSchedule && + scheduleItems == other.scheduleItems && + additionalProperties == other.additionalProperties + } - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + additionalProperties, + ) + } - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun id(id: String) = id(JsonField.of(id)) + override fun toString() = + "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amount(amount: Double) = amount(JsonField.of(amount)) + return other is UpdateDiscount && + id == other.id && + customFields == other.customFields && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + schedule == other.schedule && + additionalProperties == other.additionalProperties + } - /** - * 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 } + private val hashCode: Int by lazy { + Objects.hash( + id, + customFields, + name, + netsuiteSalesOrderId, + schedule, + additionalProperties, + ) + } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + override fun toString() = + "UpdateDiscount{id=$id, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, schedule=$schedule, additionalProperties=$additionalProperties}" + } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + class UpdatePrepaidBalanceThresholdConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commit: JsonField, + private val customCreditTypeId: JsonField, + private val discountConfiguration: JsonField, + private val isEnabled: JsonField, + private val paymentGateConfig: JsonField, + private val rechargeToAmount: JsonField, + private val thresholdAmount: JsonField, + private val thresholdBalanceSpecifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + @JsonCreator + private constructor( + @JsonProperty("commit") + @ExcludeMissing + commit: JsonField = JsonMissing.of(), + @JsonProperty("custom_credit_type_id") + @ExcludeMissing + customCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("discount_configuration") + @ExcludeMissing + discountConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("is_enabled") + @ExcludeMissing + isEnabled: JsonField = JsonMissing.of(), + @JsonProperty("payment_gate_config") + @ExcludeMissing + paymentGateConfig: JsonField = JsonMissing.of(), + @JsonProperty("recharge_to_amount") + @ExcludeMissing + rechargeToAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_balance_specifiers") + @ExcludeMissing + thresholdBalanceSpecifiers: JsonField> = + JsonMissing.of(), + ) : this( + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, + mutableMapOf(), + ) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun commit(): Optional = commit.getOptional("commit") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold + * commit amount will be in terms of this credit type instead of the fiat currency. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun customCreditTypeId(): Optional = + customCreditTypeId.getOptional("custom_credit_type_id") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun discountConfiguration(): Optional = + discountConfiguration.getOptional("discount_configuration") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * When set to false, the contract will not be evaluated against the + * threshold_amount. Toggling to true will result an immediate evaluation, + * regardless of prior state. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun paymentGateConfig(): Optional = + paymentGateConfig.getOptional("payment_gate_config") - /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } + /** + * Specify the amount the balance should be recharged to. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rechargeToAmount(): Optional = + rechargeToAmount.getOptional("recharge_to_amount") - private var validated: Boolean = false + /** + * Specify the threshold amount for the contract. Each time the contract's balance + * lowers to this amount, a threshold charge will be initiated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdAmount(): Optional = + thresholdAmount.getOptional("threshold_amount") - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Determines which balances are excluded from remaining balance calculation for + * threshold billing. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdBalanceSpecifiers(): Optional> = + thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [customCreditTypeId]. + * + * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_credit_type_id") + @ExcludeMissing + fun _customCreditTypeId(): JsonField = customCreditTypeId - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [discountConfiguration]. + * + * Unlike [discountConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("discount_configuration") + @ExcludeMissing + fun _discountConfiguration(): JsonField = + discountConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_enabled") + @ExcludeMissing + fun _isEnabled(): JsonField = isEnabled - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [paymentGateConfig]. + * + * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_gate_config") + @ExcludeMissing + fun _paymentGateConfig(): JsonField = paymentGateConfig - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) - } + /** + * Returns the raw JSON value of [rechargeToAmount]. + * + * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recharge_to_amount") + @ExcludeMissing + fun _rechargeToAmount(): JsonField = rechargeToAmount - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [thresholdBalanceSpecifiers]. + * + * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_balance_specifiers") + @ExcludeMissing + fun _thresholdBalanceSpecifiers(): JsonField> = + thresholdBalanceSpecifiers - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + /** + * Returns a mutable builder for constructing an instance of + * [UpdatePrepaidBalanceThresholdConfiguration]. + */ + @JvmStatic fun builder() = Builder() } - /** If set, the credit's rate type was updated to the specified value. */ - class RateType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + class Builder internal constructor() { + + private var commit: JsonField = JsonMissing.of() + private var customCreditTypeId: JsonField = JsonMissing.of() + private var discountConfiguration: JsonField = + JsonMissing.of() + private var isEnabled: JsonField = JsonMissing.of() + private var paymentGateConfig: JsonField = JsonMissing.of() + private var rechargeToAmount: JsonField = JsonMissing.of() + private var thresholdAmount: JsonField = JsonMissing.of() + private var thresholdBalanceSpecifiers: + JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + updatePrepaidBalanceThresholdConfiguration: + UpdatePrepaidBalanceThresholdConfiguration + ) = apply { + commit = updatePrepaidBalanceThresholdConfiguration.commit + customCreditTypeId = + updatePrepaidBalanceThresholdConfiguration.customCreditTypeId + discountConfiguration = + updatePrepaidBalanceThresholdConfiguration.discountConfiguration + isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled + paymentGateConfig = + updatePrepaidBalanceThresholdConfiguration.paymentGateConfig + rechargeToAmount = + updatePrepaidBalanceThresholdConfiguration.rechargeToAmount + thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount + thresholdBalanceSpecifiers = + updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers + .map { it.toMutableList() } + additionalProperties = + updatePrepaidBalanceThresholdConfiguration.additionalProperties + .toMutableMap() + } + + fun commit(commit: Commit) = commit(JsonField.of(commit)) /** - * Returns this class instance's raw value. + * Sets [Builder.commit] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * You should usually call [Builder.commit] with a well-typed [Commit] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun commit(commit: JsonField) = apply { this.commit = commit } - @JvmField val LIST_RATE = of("LIST_RATE") + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold + * commit amount will be in terms of this credit type instead of the fiat + * currency. + */ + fun customCreditTypeId(customCreditTypeId: String?) = + customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + /** + * Alias for calling [Builder.customCreditTypeId] with + * `customCreditTypeId.orElse(null)`. + */ + fun customCreditTypeId(customCreditTypeId: Optional) = + customCreditTypeId(customCreditTypeId.getOrNull()) - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + /** + * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.customCreditTypeId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun customCreditTypeId(customCreditTypeId: JsonField) = apply { + this.customCreditTypeId = customCreditTypeId } - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } + fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = + discountConfiguration(JsonField.ofNullable(discountConfiguration)) /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Alias for calling [Builder.discountConfiguration] with + * `discountConfiguration.orElse(null)`. */ - enum class Value { - LIST_RATE, - COMMIT_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun discountConfiguration( + discountConfiguration: Optional + ) = discountConfiguration(discountConfiguration.getOrNull()) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.discountConfiguration] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * You should usually call [Builder.discountConfiguration] with a well-typed + * [DiscountConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN - } + fun discountConfiguration( + discountConfiguration: JsonField + ) = apply { this.discountConfiguration = discountConfiguration } /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. + * When set to false, the contract will not be evaluated against the + * threshold_amount. Toggling to true will result an immediate evaluation, + * regardless of prior state. */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.isEnabled] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun isEnabled(isEnabled: JsonField) = apply { + this.isEnabled = isEnabled + } - private var validated: Boolean = false + fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = + paymentGateConfig(JsonField.of(paymentGateConfig)) /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * You should usually call [Builder.paymentGateConfig] with a well-typed + * [PaymentGateConfigV2] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun validate(): RateType = apply { - if (validated) { - return@apply + fun paymentGateConfig(paymentGateConfig: JsonField) = + apply { + this.paymentGateConfig = paymentGateConfig } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Specify the amount the balance should be recharged to. */ + fun rechargeToAmount(rechargeToAmount: Double) = + rechargeToAmount(JsonField.of(rechargeToAmount)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value + fun rechargeToAmount(rechargeToAmount: JsonField) = apply { + this.rechargeToAmount = rechargeToAmount } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Specify the threshold amount for the contract. Each time the contract's + * balance lowers to this amount, a threshold charge will be initiated. + */ + fun thresholdAmount(thresholdAmount: Double) = + thresholdAmount(JsonField.of(thresholdAmount)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount } - return other is UpdateCredit && - id == other.id && - accessSchedule == other.accessSchedule && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - priority == other.priority && - productId == other.productId && - rateType == other.rateType && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode + /** + * Determines which balances are excluded from remaining balance calculation for + * threshold billing. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: List? + ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) - override fun toString() = - "UpdateCredit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [Builder.thresholdBalanceSpecifiers] with + * `thresholdBalanceSpecifiers.orElse(null)`. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: Optional> + ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) - class UpdateDiscount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val customFields: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val schedule: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdBalanceSpecifiers] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: JsonField> + ) = apply { + this.thresholdBalanceSpecifiers = + thresholdBalanceSpecifiers.map { it.toMutableList() } + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - ) : this(id, customFields, name, netsuiteSalesOrderId, schedule, mutableMapOf()) + /** + * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdBalanceSpecifier( + thresholdBalanceSpecifier: ThresholdBalanceSpecifier + ) = apply { + thresholdBalanceSpecifiers = + (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdBalanceSpecifiers", it) + .add(thresholdBalanceSpecifier) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun customFields(): Optional = - customFields.getOptional("custom_fields") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Must provide either schedule_items or recurring_schedule. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun schedule(): Optional = schedule.getOptional("schedule") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns an immutable instance of + * [UpdatePrepaidBalanceThresholdConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdatePrepaidBalanceThresholdConfiguration = + UpdatePrepaidBalanceThresholdConfiguration( + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + private var validated: Boolean = false /** - * Returns the raw JSON value of [name]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + if (validated) { + return@apply + } + + commit().ifPresent { it.validate() } + customCreditTypeId() + discountConfiguration().ifPresent { it.validate() } + isEnabled() + paymentGateConfig().ifPresent { it.validate() } + rechargeToAmount() + thresholdAmount() + thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [schedule]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule + @JvmSynthetic + internal fun validity(): Int = + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + + (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Commit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val name: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + description, + name, + priority, + productId, + applicableProductIds, + applicableProductTags, + specifiers, + mutableMapOf(), + ) - fun toBuilder() = Builder().from(this) + fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = + UpdateBaseThresholdCommit.builder() + .description(description) + .name(name) + .priority(priority) + .productId(productId) + .build() - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Specify the name of the line item for the threshold charge. If left blank, it + * will default to the commit product name. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The priority of the commit, used to determine drawdown order. Lower priority + * commits are consumed first. Defaults to 100 if not specified. On updates, set + * to null to clear a previously configured priority. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") + + /** + * The commit product that will be used to generate the line item for commit + * payment. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") + + /** + * Which products the threshold commit applies to. If both + * applicable_product_ids and applicable_product_tags are not provided, the + * commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") /** - * Returns a mutable builder for constructing an instance of [UpdateDiscount]. + * Which tags the threshold commit applies to. If both applicable_product_ids + * and applicable_product_tags are not provided, the commit applies to all + * products. * - * The following fields are required: - * ```java - * .id() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UpdateDiscount]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(updateDiscount: UpdateDiscount) = apply { - id = updateDiscount.id - customFields = updateDiscount.customFields - name = updateDiscount.name - netsuiteSalesOrderId = updateDiscount.netsuiteSalesOrderId - schedule = updateDiscount.schedule - additionalProperties = updateDiscount.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") /** - * Sets [Builder.id] to an arbitrary JSON value. + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at least + * one of the specifiers to contribute to a commit's or credit's drawdown. This + * field cannot be used together with `applicable_product_ids` or + * `applicable_product_tags`. Instead, to target usage by product or product + * tag, pass those values in the body of `specifiers`. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } - - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = - customFields(JsonField.of(customFields)) + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") /** - * Sets [Builder.customFields] to an arbitrary JSON value. + * Returns the raw JSON value of [description]. * - * You should usually call [Builder.customFields] with a well-typed - * [CustomFields] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns the raw JSON value of [priority]. * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Unlike [priority], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun name(name: JsonField) = apply { this.name = name } + @JsonProperty("priority") + @ExcludeMissing + fun _priority(): JsonField = priority - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Returns the raw JSON value of [applicableProductIds]. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unlike [applicableProductIds], this method doesn't throw if the JSON field + * has an unexpected type. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** Must provide either schedule_items or recurring_schedule. */ - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags /** - * Sets [Builder.schedule] to an arbitrary JSON value. + * Returns the raw JSON value of [specifiers]. * - * You should usually call [Builder.schedule] with a well-typed [Schedule] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Unlike [specifiers], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - 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 [Commit]. */ + @JvmStatic fun builder() = Builder() } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + description = commit.description + name = commit.name + priority = commit.priority + productId = commit.productId + applicableProductIds = + commit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + commit.applicableProductTags.map { it.toMutableList() } + specifiers = commit.specifiers.map { it.toMutableList() } + additionalProperties = commit.additionalProperties.toMutableMap() } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun description(description: String) = + description(JsonField.of(description)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * Returns an immutable instance of [UpdateDiscount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateDiscount = - UpdateDiscount( - checkRequired("id", id), - customFields, - name, - netsuiteSalesOrderId, - schedule, - additionalProperties.toMutableMap(), - ) - } + /** + * Specify the name of the line item for the threshold charge. If left + * blank, it will default to the commit product name. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The priority of the commit, used to determine drawdown order. Lower + * priority commits are consumed first. Defaults to 100 if not specified. On + * updates, set to null to clear a previously configured priority. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) + + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun priority(priority: JsonField) = apply { + this.priority = priority + } - private var validated: Boolean = false + /** + * The commit product that will be used to generate the line item for commit + * payment. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateDiscount = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun productId(productId: JsonField) = apply { + this.productId = productId + } - id() - customFields().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - schedule().ifPresent { it.validate() } - validated = true - } + /** + * Which products the threshold commit applies to. If both + * applicable_product_ids and applicable_product_tags are not provided, the + * commit applies to all products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = + apply { + this.applicableProductIds = + applicableProductIds.map { it.toMutableList() } + } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Which tags the threshold commit applies to. If both + * applicable_product_ids and applicable_product_tags are not provided, the + * commit applies to all products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - companion object { + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = + apply { + this.applicableProductTags = + applicableProductTags.map { it.toMutableList() } + } /** - * Returns a mutable builder for constructing an instance of [CustomFields]. + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - @JvmStatic fun builder() = Builder() - } + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it) + .add(applicableProductTag) + } + } - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at + * least one of the specifiers to contribute to a commit's or credit's + * drawdown. This field cannot be used together with + * `applicable_product_ids` or `applicable_product_tags`. Instead, to target + * usage by product or product tag, pass those values in the body of + * `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. + */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } } fun additionalProperties(additionalProperties: Map) = @@ -26025,11 +31203,23 @@ private constructor( } /** - * Returns an immutable instance of [CustomFields]. + * Returns an immutable instance of [Commit]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + fun build(): Commit = + Commit( + description, + name, + priority, + productId, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { + it.toImmutable() + }, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -26044,11 +31234,18 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): CustomFields = apply { + fun validate(): Commit = apply { if (validated) { return@apply } + description() + name() + priority() + productId() + applicableProductIds() + applicableProductTags() + specifiers().ifPresent { it.forEach { it.validate() } } validated = true } @@ -26068,138 +31265,101 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CustomFields && + return other is Commit && + description == other.description && + name == other.name && + priority == other.priority && + productId == other.productId && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + specifiers == other.specifiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + description, + name, + priority, + productId, + applicableProductIds, + applicableProductTags, + specifiers, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "CustomFields{additionalProperties=$additionalProperties}" + "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" } - /** Must provide either schedule_items or recurring_schedule. */ - class Schedule + class DiscountConfiguration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val creditTypeId: JsonField, - private val doNotInvoice: JsonField, - private val recurringSchedule: JsonField, - private val scheduleItems: JsonField>, + private val cap: JsonField, + private val paymentFraction: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("do_not_invoice") - @ExcludeMissing - doNotInvoice: JsonField = JsonMissing.of(), - @JsonProperty("recurring_schedule") - @ExcludeMissing - recurringSchedule: JsonField = JsonMissing.of(), - @JsonProperty("schedule_items") + @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), + @JsonProperty("payment_fraction") @ExcludeMissing - scheduleItems: JsonField> = JsonMissing.of(), - ) : this( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - mutableMapOf(), - ) - - /** - * Defaults to USD (cents) if not passed. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): Optional = - creditTypeId.getOptional("credit_type_id") - - /** - * This field is only applicable to commit invoice schedules. If true, this - * schedule will not generate an invoice. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun doNotInvoice(): Optional = - doNotInvoice.getOptional("do_not_invoice") + paymentFraction: JsonField = JsonMissing.of(), + ) : this(cap, paymentFraction, mutableMapOf()) /** - * Enter the unit price and quantity for the charge or instead only send the - * amount. If amount is sent, the unit price is assumed to be the amount and - * quantity is inferred to be 1. + * Update the discount cap. Set to null to remove an existing cap. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun recurringSchedule(): Optional = - recurringSchedule.getOptional("recurring_schedule") + fun cap(): Optional = cap.getOptional("cap") /** - * Either provide amount or provide both unit_price and quantity. + * The fraction of the original amount that the customer pays after applying the + * discount. Set to null to remove the discount fraction. For example, 0.85 + * means the customer pays 85% of the original amount (a 15% discount). * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun scheduleItems(): Optional> = - scheduleItems.getOptional("schedule_items") - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId - - /** - * Returns the raw JSON value of [doNotInvoice]. - * - * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("do_not_invoice") - @ExcludeMissing - fun _doNotInvoice(): JsonField = doNotInvoice + fun paymentFraction(): Optional = + paymentFraction.getOptional("payment_fraction") /** - * Returns the raw JSON value of [recurringSchedule]. + * Returns the raw JSON value of [cap]. * - * Unlike [recurringSchedule], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [cap], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("recurring_schedule") - @ExcludeMissing - fun _recurringSchedule(): JsonField = recurringSchedule + @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap /** - * Returns the raw JSON value of [scheduleItems]. + * Returns the raw JSON value of [paymentFraction]. * - * Unlike [scheduleItems], this method doesn't throw if the JSON field has an + * Unlike [paymentFraction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("schedule_items") + @JsonProperty("payment_fraction") @ExcludeMissing - fun _scheduleItems(): JsonField> = scheduleItems + fun _paymentFraction(): JsonField = paymentFraction @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -26215,109 +31375,76 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Schedule]. */ + /** + * Returns a mutable builder for constructing an instance of + * [DiscountConfiguration]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Schedule]. */ + /** A builder for [DiscountConfiguration]. */ class Builder internal constructor() { - private var creditTypeId: JsonField = JsonMissing.of() - private var doNotInvoice: JsonField = JsonMissing.of() - private var recurringSchedule: JsonField = - JsonMissing.of() - private var scheduleItems: JsonField>? = null + private var cap: JsonField = JsonMissing.of() + private var paymentFraction: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - creditTypeId = schedule.creditTypeId - doNotInvoice = schedule.doNotInvoice - recurringSchedule = schedule.recurringSchedule - scheduleItems = schedule.scheduleItems.map { it.toMutableList() } - additionalProperties = schedule.additionalProperties.toMutableMap() + internal fun from(discountConfiguration: DiscountConfiguration) = apply { + cap = discountConfiguration.cap + paymentFraction = discountConfiguration.paymentFraction + additionalProperties = + discountConfiguration.additionalProperties.toMutableMap() } - /** Defaults to USD (cents) if not passed. */ - fun creditTypeId(creditTypeId: String) = - creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + /** Update the discount cap. Set to null to remove an existing cap. */ + fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - /** - * This field is only applicable to commit invoice schedules. If true, this - * schedule will not generate an invoice. - */ - fun doNotInvoice(doNotInvoice: Boolean) = - doNotInvoice(JsonField.of(doNotInvoice)) + /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ + fun cap(cap: Optional) = cap(cap.getOrNull()) /** - * Sets [Builder.doNotInvoice] to an arbitrary JSON value. + * Sets [Builder.cap] to an arbitrary JSON value. * - * You should usually call [Builder.doNotInvoice] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.cap] with a well-typed [Cap] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun doNotInvoice(doNotInvoice: JsonField) = apply { - this.doNotInvoice = doNotInvoice - } + fun cap(cap: JsonField) = apply { this.cap = cap } /** - * Enter the unit price and quantity for the charge or instead only send the - * amount. If amount is sent, the unit price is assumed to be the amount and - * quantity is inferred to be 1. + * The fraction of the original amount that the customer pays after applying + * the discount. Set to null to remove the discount fraction. For example, + * 0.85 means the customer pays 85% of the original amount (a 15% discount). */ - fun recurringSchedule(recurringSchedule: RecurringSchedule) = - recurringSchedule(JsonField.of(recurringSchedule)) + fun paymentFraction(paymentFraction: Double?) = + paymentFraction(JsonField.ofNullable(paymentFraction)) /** - * Sets [Builder.recurringSchedule] to an arbitrary JSON value. + * Alias for [Builder.paymentFraction]. * - * You should usually call [Builder.recurringSchedule] with a well-typed - * [RecurringSchedule] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun recurringSchedule(recurringSchedule: JsonField) = - apply { - this.recurringSchedule = recurringSchedule - } - - /** Either provide amount or provide both unit_price and quantity. */ - fun scheduleItems(scheduleItems: List) = - scheduleItems(JsonField.of(scheduleItems)) + fun paymentFraction(paymentFraction: Double) = + paymentFraction(paymentFraction as Double?) /** - * Sets [Builder.scheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.scheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Alias for calling [Builder.paymentFraction] with + * `paymentFraction.orElse(null)`. */ - fun scheduleItems(scheduleItems: JsonField>) = apply { - this.scheduleItems = scheduleItems.map { it.toMutableList() } - } + fun paymentFraction(paymentFraction: Optional) = + paymentFraction(paymentFraction.getOrNull()) /** - * Adds a single [ScheduleItem] to [scheduleItems]. + * Sets [Builder.paymentFraction] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.paymentFraction] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addScheduleItem(scheduleItem: ScheduleItem) = apply { - scheduleItems = - (scheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("scheduleItems", it).add(scheduleItem) - } + fun paymentFraction(paymentFraction: JsonField) = apply { + this.paymentFraction = paymentFraction } fun additionalProperties(additionalProperties: Map) = @@ -26343,16 +31470,14 @@ private constructor( } /** - * Returns an immutable instance of [Schedule]. + * Returns an immutable instance of [DiscountConfiguration]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Schedule = - Schedule( - creditTypeId, - doNotInvoice, - recurringSchedule, - (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): DiscountConfiguration = + DiscountConfiguration( + cap, + paymentFraction, additionalProperties.toMutableMap(), ) } @@ -26369,15 +31494,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Schedule = apply { + fun validate(): DiscountConfiguration = apply { if (validated) { return@apply } - creditTypeId() - doNotInvoice() - recurringSchedule().ifPresent { it.validate() } - scheduleItems().ifPresent { it.forEach { it.validate() } } + cap().ifPresent { it.validate() } + paymentFraction() validated = true } @@ -26389,176 +31512,54 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (doNotInvoice.asKnown().isPresent) 1 else 0) + - (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) - - /** - * Enter the unit price and quantity for the charge or instead only send the - * amount. If amount is sent, the unit price is assumed to be the amount and - * quantity is inferred to be 1. + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class RecurringSchedule + @JvmSynthetic + internal fun validity(): Int = + (cap.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentFraction.asKnown().isPresent) 1 else 0) + + /** Update the discount cap. Set to null to remove an existing cap. */ + class Cap @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val amountDistribution: JsonField, - private val endingBefore: JsonField, - private val frequency: JsonField, - private val startingAt: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, + private val spendTrackerAlias: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount_distribution") - @ExcludeMissing - amountDistribution: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - frequency: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - mutableMapOf(), - ) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun amountDistribution(): AmountDistribution = - amountDistribution.getRequired("amount_distribution") + spendTrackerAlias: JsonField = JsonMissing.of(), + ) : this(amount, spendTrackerAlias, mutableMapOf()) /** - * RFC 3339 timestamp (exclusive). + * Accumulated spend ceiling above which the discount stops applying. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun endingBefore(): OffsetDateTime = - endingBefore.getRequired("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun frequency(): Frequency = frequency.getRequired("frequency") + fun amount(): Double = amount.getRequired("amount") /** - * RFC 3339 timestamp (inclusive). + * Alias of the spend tracker this cap is measured against. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - - /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the amount - * and quantity is inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Quantity for the charge. Will be multiplied by unit_price to determine - * the amount and must be specified with unit_price. If specified amount - * cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * Unit price for the charge. Will be multiplied by quantity to determine - * the amount and must be specified with quantity. If specified amount - * cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - - /** - * Returns the raw JSON value of [amountDistribution]. - * - * Unlike [amountDistribution], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("amount_distribution") - @ExcludeMissing - fun _amountDistribution(): JsonField = - amountDistribution - - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [frequency]. - * - * Unlike [frequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun spendTrackerAlias(): String = + spendTrackerAlias.getRequired("spend_tracker_alias") /** * Returns the raw JSON value of [amount]. @@ -26571,24 +31572,14 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [spendTrackerAlias]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _spendTrackerAlias(): JsonField = spendTrackerAlias @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -26605,108 +31596,34 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [RecurringSchedule]. + * Returns a mutable builder for constructing an instance of [Cap]. * * The following fields are required: * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() + * .amount() + * .spendTrackerAlias() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [RecurringSchedule]. */ + /** A builder for [Cap]. */ class Builder internal constructor() { - private var amountDistribution: JsonField? = null - private var endingBefore: JsonField? = null - private var frequency: JsonField? = null - private var startingAt: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var spendTrackerAlias: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(recurringSchedule: RecurringSchedule) = apply { - amountDistribution = recurringSchedule.amountDistribution - endingBefore = recurringSchedule.endingBefore - frequency = recurringSchedule.frequency - startingAt = recurringSchedule.startingAt - amount = recurringSchedule.amount - quantity = recurringSchedule.quantity - unitPrice = recurringSchedule.unitPrice - additionalProperties = - recurringSchedule.additionalProperties.toMutableMap() - } - - fun amountDistribution(amountDistribution: AmountDistribution) = - amountDistribution(JsonField.of(amountDistribution)) - - /** - * Sets [Builder.amountDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.amountDistribution] with a - * well-typed [AmountDistribution] value instead. This method is - * primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amountDistribution( - amountDistribution: JsonField - ) = apply { this.amountDistribution = amountDistribution } - - /** RFC 3339 timestamp (exclusive). */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) - - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) - - /** - * Sets [Builder.frequency] to an arbitrary JSON value. - * - * You should usually call [Builder.frequency] with a well-typed - * [Frequency] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } - - /** RFC 3339 timestamp (inclusive). */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) - - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + + @JvmSynthetic + internal fun from(cap: Cap) = apply { + amount = cap.amount + spendTrackerAlias = cap.spendTrackerAlias + additionalProperties = cap.additionalProperties.toMutableMap() } /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the - * amount and quantity is inferred to be 1. + * Accumulated spend ceiling above which the discount stops applying. */ fun amount(amount: Double) = amount(JsonField.of(amount)) @@ -26719,40 +31636,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * Quantity for the charge. Will be multiplied by unit_price to - * determine the amount and must be specified with unit_price. If - * specified amount cannot be provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } - - /** - * Unit price for the charge. Will be multiplied by quantity to - * determine the amount and must be specified with quantity. If - * specified amount cannot be provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** Alias of the spend tracker this cap is measured against. */ + fun spendTrackerAlias(spendTrackerAlias: String) = + spendTrackerAlias(JsonField.of(spendTrackerAlias)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed - * [Double] value instead. This method is primarily for setting the + * You should usually call [Builder.spendTrackerAlias] with a well-typed + * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { + this.spendTrackerAlias = spendTrackerAlias } fun additionalProperties(additionalProperties: Map) = @@ -26778,780 +31674,924 @@ private constructor( } /** - * Returns an immutable instance of [RecurringSchedule]. + * Returns an immutable instance of [Cap]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() + * .amount() + * .spendTrackerAlias() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RecurringSchedule = - RecurringSchedule( - checkRequired("amountDistribution", amountDistribution), - checkRequired("endingBefore", endingBefore), - checkRequired("frequency", frequency), - checkRequired("startingAt", startingAt), - amount, - quantity, - unitPrice, + fun build(): Cap = + Cap( + checkRequired("amount", amount), + checkRequired("spendTrackerAlias", spendTrackerAlias), additionalProperties.toMutableMap(), ) } - private var validated: Boolean = false + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Cap = apply { + if (validated) { + return@apply + } + + amount() + spendTrackerAlias() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a 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 (spendTrackerAlias.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cap && + amount == other.amount && + spendTrackerAlias == other.spendTrackerAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, spendTrackerAlias, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DiscountConfiguration && + cap == other.cap && + paymentFraction == other.paymentFraction && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cap, paymentFraction, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" + } + + class ThresholdBalanceSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of() + ) : this(exclude, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun exclude(): List = exclude.getRequired("exclude") + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("exclude") + @ExcludeMissing + fun _exclude(): JsonField> = exclude + + @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 + * [ThresholdBalanceSpecifier]. + * + * The following fields are required: + * ```java + * .exclude() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdBalanceSpecifier]. */ + class Builder internal constructor() { + + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = + apply { + exclude = + thresholdBalanceSpecifier.exclude.map { it.toMutableList() } + additionalProperties = + thresholdBalanceSpecifier.additionalProperties.toMutableMap() + } + + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + + /** + * Sets [Builder.exclude] to an arbitrary JSON value. + * + * You should usually call [Builder.exclude] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Validates that the types of all values in this object match their - * expected types recursively. + * Returns an immutable instance of [ThresholdBalanceSpecifier]. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * The following fields are required: + * ```java + * .exclude() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun validate(): RecurringSchedule = apply { - if (validated) { - return@apply - } + fun build(): ThresholdBalanceSpecifier = + ThresholdBalanceSpecifier( + checkRequired("exclude", exclude).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - amountDistribution().validate() - endingBefore() - frequency().validate() - startingAt() - amount() - quantity() - unitPrice() - validated = true + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): ThresholdBalanceSpecifier = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + exclude().forEach { it.validate() } + validated = true + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (frequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - class AmountDistribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + class Exclude + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = + JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) - @JvmField val DIVIDED = of("DIVIDED") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun customFieldFilters(): List = + customFieldFilters.getRequired("custom_field_filters") - @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = + customFieldFilters - @JvmField val EACH = of("EACH") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmStatic - fun of(value: String) = AmountDistribution(JsonField.of(value)) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** An enum containing [AmountDistribution]'s known values. */ - enum class Known { - DIVIDED, - DIVIDED_ROUNDED, - EACH, - } + fun toBuilder() = Builder().from(this) - /** - * An enum containing [AmountDistribution]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AmountDistribution] can contain an unknown value in a - * couple of cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDED, - DIVIDED_ROUNDED, - EACH, - /** - * An enum member indicating that [AmountDistribution] was - * instantiated with an unknown value. - */ - _UNKNOWN, - } + companion object { /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. + * Returns a mutable builder for constructing an instance of [Exclude]. * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` */ - fun value(): Value = - when (this) { - DIVIDED -> Value.DIVIDED - DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED - EACH -> Value.EACH - else -> Value._UNKNOWN - } + @JvmStatic fun builder() = Builder() + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - DIVIDED -> Known.DIVIDED - DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED - EACH -> Known.EACH - else -> - throw MetronomeInvalidDataException( - "Unknown AmountDistribution: $value" - ) - } + /** A builder for [Exclude]. */ + class Builder internal constructor() { - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + private var customFieldFilters: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(exclude: Exclude) = apply { + customFieldFilters = + exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() + } - private var validated: Boolean = false + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API - * for existing fields. + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this - * object doesn't match its expected type. + * You should usually call [Builder.customFieldFilters] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): AmountDistribution = apply { - if (validated) { - return@apply - } - - known() - validated = true + fun customFieldFilters( + customFieldFilters: JsonField> + ) = apply { + this.customFieldFilters = + customFieldFilters.map { it.toMutableList() } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. + * Adds a single [CustomFieldFilter] to [customFieldFilters]. * - * Used for best match union deserialization. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - return other is AmountDistribution && value == other.value + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun hashCode() = value.hashCode() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun toString() = value.toString() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - class Frequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns this class instance's raw value. + * Returns an immutable instance of [Exclude]. * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + fun build(): Exclude = + Exclude( + checkRequired("customFieldFilters", customFieldFilters).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } - @JvmField val MONTHLY = of("MONTHLY") + private var validated: Boolean = false - @JvmField val QUARTERLY = of("QUARTERLY") + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Exclude = apply { + if (validated) { + return@apply + } - @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") + customFieldFilters().forEach { it.validate() } + validated = true + } - @JvmField val ANNUAL = of("ANNUAL") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val WEEKLY = of("WEEKLY") + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) - @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) - } + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [Frequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, - } + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") + @ExcludeMissing + key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) /** - * An enum containing [Frequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Frequency] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws MetronomeInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). */ - enum class Value { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [Frequency] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + fun entity(): Entity = entity.getRequired("entity") /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + fun key(): String = key.getRequired("key") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value - * is a not a known member. + * @throws MetronomeInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown Frequency: $value" - ) - } + fun value(): String = value.getRequired("value") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. + * Returns the raw JSON value of [entity]. * - * @throws MetronomeInvalidDataException if this class instance's value - * does not have the expected primitive type. + * Unlike [entity], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("entity") + @ExcludeMissing + fun _entity(): JsonField = entity /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API - * for existing fields. + * Returns the raw JSON value of [key]. * - * @throws MetronomeInvalidDataException if any value type in this - * object doesn't match its expected type. + * Unlike [key], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun validate(): Frequency = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** - * Returns a score indicating how many valid values are contained in - * this object recursively. + * Returns the raw JSON value of [value]. * - * Used for best match union deserialization. + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Frequency && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is RecurringSchedule && - amountDistribution == other.amountDistribution && - endingBefore == other.endingBefore && - frequency == other.frequency && - startingAt == other.startingAt && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class ScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val timestamp: JsonField, - private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + companion object { - /** - * timestamp of the scheduled event - * - * @throws MetronomeInvalidDataException if 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") + /** + * Returns a mutable builder for constructing an instance of + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the amount - * and quantity is inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { - /** - * Quantity for the charge. Will be multiplied by unit_price to determine - * the amount and must be specified with unit_price. If specified amount - * cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Unit price for the charge. Will be multiplied by quantity to determine - * the amount and must be specified with quantity. If specified amount - * cannot be provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = + customFieldFilter.additionalProperties.toMutableMap() + } - /** - * 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 + fun entity(entity: Entity) = entity(JsonField.of(entity)) - /** - * 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 + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed + * [Entity] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun entity(entity: JsonField) = apply { + this.entity = entity + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + fun key(key: String) = key(JsonField.of(key)) - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun value(value: String) = value(JsonField.of(value)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } - fun toBuilder() = Builder().from(this) + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [ScheduleItem]. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** A builder for [ScheduleItem]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(scheduleItem: ScheduleItem) = apply { - timestamp = scheduleItem.timestamp - amount = scheduleItem.amount - quantity = scheduleItem.quantity - unitPrice = scheduleItem.unitPrice - additionalProperties = - scheduleItem.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) } - /** timestamp of the scheduled event */ - fun timestamp(timestamp: OffsetDateTime) = - timestamp(JsonField.of(timestamp)) + private var validated: Boolean = false /** - * Sets [Builder.timestamp] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.timestamp] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. */ - fun timestamp(timestamp: JsonField) = apply { - this.timestamp = timestamp + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true } - /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the - * amount and quantity is inferred to be 1. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.amount] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in + * this object recursively. * - * 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. + * Used for best match union deserialization. */ - fun amount(amount: JsonField) = apply { this.amount = amount } + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) - /** - * Quantity for the charge. Will be multiplied by unit_price to - * determine the amount and must be specified with unit_price. If - * specified amount cannot be provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized + * from data that doesn't match any known member, and you want to + * know that value. For example, if the SDK is on an older version + * than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField + val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Entity] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known + * member. For example, if the SDK is on an older version than the + * API, then the API may respond with new members that the SDK is + * unaware of. + * - It was constructed with an arbitrary value using the [of] + * method. + */ + enum class Value { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's + * value, or [Value._UNKNOWN] if the class was instantiated with an + * unknown value. + * + * Use the [known] method instead if you're certain the value is + * always known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's + * value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's + * value is a not a known member. + */ + fun known(): Known = + when (this) { + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> + throw MetronomeInvalidDataException( + "Unknown Entity: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's + * value does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the + * API for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } - /** - * Unit price for the charge. Will be multiplied by quantity to - * determine the amount and must be specified with quantity. If - * specified amount cannot be provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + known() + validated = true + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed - * [Double] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + if (value() == Value._UNKNOWN) 0 else 1 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + return other is Entity && value == other.value + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun hashCode() = value.hashCode() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun toString() = value.toString() } - /** - * Returns an immutable instance of [ScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScheduleItem = - ScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): ScheduleItem = apply { - if (validated) { - return@apply + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties } - timestamp() - amount() - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScheduleItem && - timestamp == other.timestamp && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && + return other is Exclude && + customFieldFilters == other.customFieldFilters && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - timestamp, - amount, - quantity, - unitPrice, - additionalProperties, - ) + Objects.hash(customFieldFilters, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -27559,28 +32599,19 @@ private constructor( return true } - return other is Schedule && - creditTypeId == other.creditTypeId && - doNotInvoice == other.doNotInvoice && - recurringSchedule == other.recurringSchedule && - scheduleItems == other.scheduleItems && + return other is ThresholdBalanceSpecifier && + exclude == other.exclude && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - additionalProperties, - ) + Objects.hash(exclude, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -27588,22 +32619,28 @@ private constructor( return true } - return other is UpdateDiscount && - id == other.id && - customFields == other.customFields && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - schedule == other.schedule && + return other is UpdatePrepaidBalanceThresholdConfiguration && + commit == other.commit && + customCreditTypeId == other.customCreditTypeId && + discountConfiguration == other.discountConfiguration && + isEnabled == other.isEnabled && + paymentGateConfig == other.paymentGateConfig && + rechargeToAmount == other.rechargeToAmount && + thresholdAmount == other.thresholdAmount && + thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - customFields, - name, - netsuiteSalesOrderId, - schedule, + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, additionalProperties, ) } @@ -27611,207 +32648,148 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateDiscount{id=$id, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, schedule=$schedule, additionalProperties=$additionalProperties}" + "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" } - class UpdatePrepaidBalanceThresholdConfiguration + class UpdateRecurringCommit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val commit: JsonField, - private val customCreditTypeId: JsonField, - private val discountConfiguration: JsonField, - private val isEnabled: JsonField, - private val paymentGateConfig: JsonField, - private val rechargeToAmount: JsonField, - private val thresholdAmount: JsonField, - private val thresholdBalanceSpecifiers: JsonField>, + private val id: JsonField, + private val accessAmount: JsonField, + private val endingBefore: JsonField, + private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("commit") - @ExcludeMissing - commit: JsonField = JsonMissing.of(), - @JsonProperty("custom_credit_type_id") - @ExcludeMissing - customCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("discount_configuration") - @ExcludeMissing - discountConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("is_enabled") - @ExcludeMissing - isEnabled: JsonField = JsonMissing.of(), - @JsonProperty("payment_gate_config") - @ExcludeMissing - paymentGateConfig: JsonField = JsonMissing.of(), - @JsonProperty("recharge_to_amount") + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") @ExcludeMissing - rechargeToAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_amount") + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") @ExcludeMissing - thresholdAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_balance_specifiers") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("invoice_amount") @ExcludeMissing - thresholdBalanceSpecifiers: JsonField> = - JsonMissing.of(), - ) : this( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + invoiceAmount: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + ) : this( + id, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, mutableMapOf(), ) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun commit(): Optional = commit.getOptional("commit") - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold - * commit amount will be in terms of this credit type instead of the fiat currency. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun customCreditTypeId(): Optional = - customCreditTypeId.getOptional("custom_credit_type_id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun discountConfiguration(): Optional = - discountConfiguration.getOptional("discount_configuration") + fun id(): String = id.getRequired("id") /** - * When set to false, the contract will not be evaluated against the - * threshold_amount. Toggling to true will result an immediate evaluation, - * regardless of prior state. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") + fun accessAmount(): Optional = + accessAmount.getOptional("access_amount") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun paymentGateConfig(): Optional = - paymentGateConfig.getOptional("payment_gate_config") + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** - * Specify the amount the balance should be recharged to. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun rechargeToAmount(): Optional = - rechargeToAmount.getOptional("recharge_to_amount") + fun invoiceAmount(): Optional = + invoiceAmount.getOptional("invoice_amount") /** - * Specify the threshold amount for the contract. Each time the contract's balance - * lowers to this amount, a threshold charge will be initiated. + * Rounding configuration for prorated recurring commit amounts. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun thresholdAmount(): Optional = - thresholdAmount.getOptional("threshold_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun thresholdBalanceSpecifiers(): Optional> = - thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") + fun rateType(): Optional = rateType.getOptional("rate_type") /** - * Returns the raw JSON value of [commit]. + * Returns the raw JSON value of [id]. * - * Unlike [commit], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [customCreditTypeId]. + * Returns the raw JSON value of [accessAmount]. * - * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an + * Unlike [accessAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("custom_credit_type_id") - @ExcludeMissing - fun _customCreditTypeId(): JsonField = customCreditTypeId - - /** - * Returns the raw JSON value of [discountConfiguration]. - * - * Unlike [discountConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("discount_configuration") - @ExcludeMissing - fun _discountConfiguration(): JsonField = - discountConfiguration - - /** - * Returns the raw JSON value of [isEnabled]. - * - * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("is_enabled") + @JsonProperty("access_amount") @ExcludeMissing - fun _isEnabled(): JsonField = isEnabled + fun _accessAmount(): JsonField = accessAmount /** - * Returns the raw JSON value of [paymentGateConfig]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("payment_gate_config") + @JsonProperty("ending_before") @ExcludeMissing - fun _paymentGateConfig(): JsonField = paymentGateConfig + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [rechargeToAmount]. + * Returns the raw JSON value of [invoiceAmount]. * - * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an + * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("recharge_to_amount") + @JsonProperty("invoice_amount") @ExcludeMissing - fun _rechargeToAmount(): JsonField = rechargeToAmount + fun _invoiceAmount(): JsonField = invoiceAmount /** - * Returns the raw JSON value of [thresholdAmount]. + * Returns the raw JSON value of [prorationRounding]. * - * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("threshold_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _thresholdAmount(): JsonField = thresholdAmount + fun _prorationRounding(): JsonField = prorationRounding /** - * Returns the raw JSON value of [thresholdBalanceSpecifiers]. + * Returns the raw JSON value of [rateType]. * - * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("threshold_balance_specifiers") + @JsonProperty("rate_type") @ExcludeMissing - fun _thresholdBalanceSpecifiers(): JsonField> = - thresholdBalanceSpecifiers + fun _rateType(): JsonField = rateType @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27829,217 +32807,124 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UpdatePrepaidBalanceThresholdConfiguration]. + * [UpdateRecurringCommit]. + * + * The following fields are required: + * ```java + * .id() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + /** A builder for [UpdateRecurringCommit]. */ class Builder internal constructor() { - private var commit: JsonField = JsonMissing.of() - private var customCreditTypeId: JsonField = JsonMissing.of() - private var discountConfiguration: JsonField = - JsonMissing.of() - private var isEnabled: JsonField = JsonMissing.of() - private var paymentGateConfig: JsonField = JsonMissing.of() - private var rechargeToAmount: JsonField = JsonMissing.of() - private var thresholdAmount: JsonField = JsonMissing.of() - private var thresholdBalanceSpecifiers: - JsonField>? = - null + private var id: JsonField? = null + private var accessAmount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - updatePrepaidBalanceThresholdConfiguration: - UpdatePrepaidBalanceThresholdConfiguration - ) = apply { - commit = updatePrepaidBalanceThresholdConfiguration.commit - customCreditTypeId = - updatePrepaidBalanceThresholdConfiguration.customCreditTypeId - discountConfiguration = - updatePrepaidBalanceThresholdConfiguration.discountConfiguration - isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled - paymentGateConfig = - updatePrepaidBalanceThresholdConfiguration.paymentGateConfig - rechargeToAmount = - updatePrepaidBalanceThresholdConfiguration.rechargeToAmount - thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount - thresholdBalanceSpecifiers = - updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers - .map { it.toMutableList() } + internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { + id = updateRecurringCommit.id + accessAmount = updateRecurringCommit.accessAmount + endingBefore = updateRecurringCommit.endingBefore + invoiceAmount = updateRecurringCommit.invoiceAmount + prorationRounding = updateRecurringCommit.prorationRounding + rateType = updateRecurringCommit.rateType additionalProperties = - updatePrepaidBalanceThresholdConfiguration.additionalProperties - .toMutableMap() - } - - fun commit(commit: Commit) = commit(JsonField.of(commit)) - - /** - * Sets [Builder.commit] to an arbitrary JSON value. - * - * You should usually call [Builder.commit] with a well-typed [Commit] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun commit(commit: JsonField) = apply { this.commit = commit } - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold - * commit amount will be in terms of this credit type instead of the fiat - * currency. - */ - fun customCreditTypeId(customCreditTypeId: String?) = - customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) - - /** - * Alias for calling [Builder.customCreditTypeId] with - * `customCreditTypeId.orElse(null)`. - */ - fun customCreditTypeId(customCreditTypeId: Optional) = - customCreditTypeId(customCreditTypeId.getOrNull()) - - /** - * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.customCreditTypeId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun customCreditTypeId(customCreditTypeId: JsonField) = apply { - this.customCreditTypeId = customCreditTypeId + updateRecurringCommit.additionalProperties.toMutableMap() } - fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = - discountConfiguration(JsonField.ofNullable(discountConfiguration)) - - /** - * Alias for calling [Builder.discountConfiguration] with - * `discountConfiguration.orElse(null)`. - */ - fun discountConfiguration( - discountConfiguration: Optional - ) = discountConfiguration(discountConfiguration.getOrNull()) - - /** - * Sets [Builder.discountConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.discountConfiguration] with a well-typed - * [DiscountConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun discountConfiguration( - discountConfiguration: JsonField - ) = apply { this.discountConfiguration = discountConfiguration } - - /** - * When set to false, the contract will not be evaluated against the - * threshold_amount. Toggling to true will result an immediate evaluation, - * regardless of prior state. - */ - fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.isEnabled] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * You should usually call [Builder.id] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun isEnabled(isEnabled: JsonField) = apply { - this.isEnabled = isEnabled - } + fun id(id: JsonField) = apply { this.id = id } - fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = - paymentGateConfig(JsonField.of(paymentGateConfig)) + fun accessAmount(accessAmount: AccessAmount) = + accessAmount(JsonField.of(accessAmount)) /** - * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. + * Sets [Builder.accessAmount] to an arbitrary JSON value. * - * You should usually call [Builder.paymentGateConfig] with a well-typed - * [PaymentGateConfigV2] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.accessAmount] with a well-typed + * [AccessAmount] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun paymentGateConfig(paymentGateConfig: JsonField) = - apply { - this.paymentGateConfig = paymentGateConfig - } + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } - /** Specify the amount the balance should be recharged to. */ - fun rechargeToAmount(rechargeToAmount: Double) = - rechargeToAmount(JsonField.of(rechargeToAmount)) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun rechargeToAmount(rechargeToAmount: JsonField) = apply { - this.rechargeToAmount = rechargeToAmount + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - /** - * Specify the threshold amount for the contract. Each time the contract's - * balance lowers to this amount, a threshold charge will be initiated. - */ - fun thresholdAmount(thresholdAmount: Double) = - thresholdAmount(JsonField.of(thresholdAmount)) + fun invoiceAmount(invoiceAmount: InvoiceAmount) = + invoiceAmount(JsonField.of(invoiceAmount)) /** - * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * Sets [Builder.invoiceAmount] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdAmount] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.invoiceAmount] with a well-typed + * [InvoiceAmount] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun thresholdAmount(thresholdAmount: JsonField) = apply { - this.thresholdAmount = thresholdAmount + fun invoiceAmount(invoiceAmount: JsonField) = apply { + this.invoiceAmount = invoiceAmount } - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: List? - ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Alias for calling [Builder.thresholdBalanceSpecifiers] with - * `thresholdBalanceSpecifiers.orElse(null)`. + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: Optional> - ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) /** - * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdBalanceSpecifiers] with a - * well-typed `List` value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: JsonField> - ) = apply { - this.thresholdBalanceSpecifiers = - thresholdBalanceSpecifiers.map { it.toMutableList() } + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** - * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * Sets [Builder.rateType] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addThresholdBalanceSpecifier( - thresholdBalanceSpecifier: ThresholdBalanceSpecifier - ) = apply { - thresholdBalanceSpecifiers = - (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("thresholdBalanceSpecifiers", it) - .add(thresholdBalanceSpecifier) - } - } + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28064,23 +32949,25 @@ private constructor( } /** - * Returns an immutable instance of - * [UpdatePrepaidBalanceThresholdConfiguration]. + * Returns an immutable instance of [UpdateRecurringCommit]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdatePrepaidBalanceThresholdConfiguration = - UpdatePrepaidBalanceThresholdConfiguration( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { - it.toImmutable() - }, + fun build(): UpdateRecurringCommit = + UpdateRecurringCommit( + checkRequired("id", id), + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties.toMutableMap(), ) } @@ -28097,19 +32984,17 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + fun validate(): UpdateRecurringCommit = apply { if (validated) { return@apply } - commit().ifPresent { it.validate() } - customCreditTypeId() - discountConfiguration().ifPresent { it.validate() } - isEnabled() - paymentGateConfig().ifPresent { it.validate() } - rechargeToAmount() - thresholdAmount() - thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + id() + accessAmount().ifPresent { it.validate() } + endingBefore() + invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } validated = true } @@ -28129,209 +33014,62 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (commit.asKnown().getOrNull()?.validity() ?: 0) + - (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + - (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (isEnabled.asKnown().isPresent) 1 else 0) + - (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + - (if (thresholdAmount.asKnown().isPresent) 1 else 0) + - (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) - class Commit + class AccessAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val description: JsonField, - private val name: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val specifiers: JsonField>, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") + @JsonProperty("quantity") @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("specifiers") + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - mutableMapOf(), - ) - - fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = - UpdateBaseThresholdCommit.builder() - .description(description) - .name(name) - .priority(priority) - .productId(productId) - .build() - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Specify the name of the line item for the threshold charge. If left blank, it - * will default to the commit product name. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The priority of the commit, used to determine drawdown order. Lower priority - * commits are consumed first. Defaults to 100 if not specified. On updates, set - * to null to clear a previously configured priority. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") - - /** - * The commit product that will be used to generate the line item for commit - * payment. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") - - /** - * Which products the threshold commit applies to. If both - * applicable_product_ids and applicable_product_tags are not provided, the - * commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") - - /** - * Which tags the threshold commit applies to. If both applicable_product_ids - * and applicable_product_tags are not provided, the commit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at least - * one of the specifiers to contribute to a commit's or credit's drawdown. This - * field cannot be used together with `applicable_product_ids` or - * `applicable_product_tags`. Instead, to target usage by product or product - * tag, pass those values in the body of `specifiers`. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun quantity(): Optional = quantity.getOptional("quantity") /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - @JsonProperty("priority") - @ExcludeMissing - fun _priority(): JsonField = priority + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") /** - * Returns the raw JSON value of [productId]. + * Returns the raw JSON value of [quantity]. * - * Unlike [productId], this method doesn't throw if the JSON field has an + * Unlike [quantity], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId - - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds - - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("applicable_product_tags") + @JsonProperty("quantity") @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [specifiers]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [specifiers], this method doesn't throw if the JSON field has an + * Unlike [unitPrice], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("specifiers") + @JsonProperty("unit_price") @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28339,242 +33077,59 @@ private constructor( } @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Commit]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Commit]. */ - class Builder internal constructor() { - - private var description: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(commit: Commit) = apply { - description = commit.description - name = commit.name - priority = commit.priority - productId = commit.productId - applicableProductIds = - commit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - commit.applicableProductTags.map { it.toMutableList() } - specifiers = commit.specifiers.map { it.toMutableList() } - additionalProperties = commit.additionalProperties.toMutableMap() - } - - fun description(description: String) = - description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * Specify the name of the line item for the threshold charge. If left - * blank, it will default to the commit product name. - */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The priority of the commit, used to determine drawdown order. Lower - * priority commits are consumed first. Defaults to 100 if not specified. On - * updates, set to null to clear a previously configured priority. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) - - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) - - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun priority(priority: JsonField) = apply { - this.priority = priority - } - - /** - * The commit product that will be used to generate the line item for commit - * payment. - */ - fun productId(productId: String) = productId(JsonField.of(productId)) - - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun productId(productId: JsonField) = apply { - this.productId = productId - } - - /** - * Which products the threshold commit applies to. If both - * applicable_product_ids and applicable_product_tags are not provided, the - * commit applies to all products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) - - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) - - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = - apply { - this.applicableProductIds = - applicableProductIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } - - /** - * Which tags the threshold commit applies to. If both - * applicable_product_ids and applicable_product_tags are not provided, the - * commit applies to all products. - */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) - - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) - - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = - apply { - this.applicableProductTags = - applicableProductTags.map { it.toMutableList() } - } + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it) - .add(applicableProductTag) - } - } + fun toBuilder() = Builder().from(this) - /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at - * least one of the specifiers to contribute to a commit's or credit's - * drawdown. This field cannot be used together with - * `applicable_product_ids` or `applicable_product_tags`. Instead, to target - * usage by product or product tag, pass those values in the body of - * `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + companion object { /** - * Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. + * Returns a mutable builder for constructing an instance of [AccessAmount]. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { + + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + quantity = accessAmount.quantity + unitPrice = accessAmount.unitPrice + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity } + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = @@ -28600,23 +33155,12 @@ private constructor( } /** - * Returns an immutable instance of [Commit]. + * Returns an immutable instance of [AccessAmount]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Commit = - Commit( - description, - name, - priority, - productId, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { - it.toImmutable() - }, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): AccessAmount = + AccessAmount(quantity, unitPrice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -28631,18 +33175,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Commit = apply { + fun validate(): AccessAmount = apply { if (validated) { return@apply } - description() - name() - priority() - productId() - applicableProductIds() - applicableProductTags() - specifiers().ifPresent { it.forEach { it.validate() } } + quantity() + unitPrice() validated = true } @@ -28662,101 +33201,79 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (description.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Commit && - description == other.description && - name == other.name && - priority == other.priority && - productId == other.productId && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - specifiers == other.specifiers && + return other is AccessAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - additionalProperties, - ) + Objects.hash(quantity, unitPrice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" + "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class DiscountConfiguration + class InvoiceAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cap: JsonField, - private val paymentFraction: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), - @JsonProperty("payment_fraction") + @JsonProperty("quantity") @ExcludeMissing - paymentFraction: JsonField = JsonMissing.of(), - ) : this(cap, paymentFraction, mutableMapOf()) + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) /** - * Update the discount cap. Set to null to remove an existing cap. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun cap(): Optional = cap.getOptional("cap") + fun quantity(): Optional = quantity.getOptional("quantity") /** - * The fraction of the original amount that the customer pays after applying the - * discount. Set to null to remove the discount fraction. For example, 0.85 - * means the customer pays 85% of the original amount (a 15% discount). - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun paymentFraction(): Optional = - paymentFraction.getOptional("payment_fraction") + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") /** - * Returns the raw JSON value of [cap]. + * Returns the raw JSON value of [quantity]. * - * Unlike [cap], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [paymentFraction]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [paymentFraction], this method doesn't throw if the JSON field has an + * Unlike [unitPrice], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("payment_fraction") + @JsonProperty("unit_price") @ExcludeMissing - fun _paymentFraction(): JsonField = paymentFraction + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28774,74 +33291,50 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [DiscountConfiguration]. + * [InvoiceAmount]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DiscountConfiguration]. */ + /** A builder for [InvoiceAmount]. */ class Builder internal constructor() { - private var cap: JsonField = JsonMissing.of() - private var paymentFraction: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(discountConfiguration: DiscountConfiguration) = apply { - cap = discountConfiguration.cap - paymentFraction = discountConfiguration.paymentFraction - additionalProperties = - discountConfiguration.additionalProperties.toMutableMap() + internal fun from(invoiceAmount: InvoiceAmount) = apply { + quantity = invoiceAmount.quantity + unitPrice = invoiceAmount.unitPrice + additionalProperties = invoiceAmount.additionalProperties.toMutableMap() } - /** Update the discount cap. Set to null to remove an existing cap. */ - fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - - /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ - fun cap(cap: Optional) = cap(cap.getOrNull()) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.cap] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.cap] with a well-typed [Cap] value - * instead. This method is primarily for setting the field to an + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun cap(cap: JsonField) = apply { this.cap = cap } - - /** - * The fraction of the original amount that the customer pays after applying - * the discount. Set to null to remove the discount fraction. For example, - * 0.85 means the customer pays 85% of the original amount (a 15% discount). - */ - fun paymentFraction(paymentFraction: Double?) = - paymentFraction(JsonField.ofNullable(paymentFraction)) - - /** - * Alias for [Builder.paymentFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun paymentFraction(paymentFraction: Double) = - paymentFraction(paymentFraction as Double?) + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } - /** - * Alias for calling [Builder.paymentFraction] with - * `paymentFraction.orElse(null)`. - */ - fun paymentFraction(paymentFraction: Optional) = - paymentFraction(paymentFraction.getOrNull()) + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Sets [Builder.paymentFraction] to an arbitrary JSON value. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * You should usually call [Builder.paymentFraction] with a well-typed - * [Double] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun paymentFraction(paymentFraction: JsonField) = apply { - this.paymentFraction = paymentFraction + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = @@ -28867,16 +33360,12 @@ private constructor( } /** - * Returns an immutable instance of [DiscountConfiguration]. + * Returns an immutable instance of [InvoiceAmount]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DiscountConfiguration = - DiscountConfiguration( - cap, - paymentFraction, - additionalProperties.toMutableMap(), - ) + fun build(): InvoiceAmount = + InvoiceAmount(quantity, unitPrice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -28891,13 +33380,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): DiscountConfiguration = apply { + fun validate(): InvoiceAmount = apply { if (validated) { return@apply } - cap().ifPresent { it.validate() } - paymentFraction() + quantity() + unitPrice() validated = true } @@ -28917,294 +33406,80 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cap.asKnown().getOrNull()?.validity() ?: 0) + - (if (paymentFraction.asKnown().isPresent) 1 else 0) - - /** Update the discount cap. Set to null to remove an existing cap. */ - class Cap - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val spendTrackerAlias: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("spend_tracker_alias") - @ExcludeMissing - spendTrackerAlias: JsonField = JsonMissing.of(), - ) : this(amount, spendTrackerAlias, mutableMapOf()) - - /** - * Accumulated spend ceiling above which the discount stops applying. - * - * @throws MetronomeInvalidDataException if 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") - - /** - * Alias of the spend tracker this cap is measured against. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun spendTrackerAlias(): String = - spendTrackerAlias.getRequired("spend_tracker_alias") - - /** - * 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 [spendTrackerAlias]. - * - * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("spend_tracker_alias") - @ExcludeMissing - fun _spendTrackerAlias(): JsonField = spendTrackerAlias - - @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 [Cap]. - * - * The following fields are required: - * ```java - * .amount() - * .spendTrackerAlias() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Cap]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var spendTrackerAlias: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(cap: Cap) = apply { - amount = cap.amount - spendTrackerAlias = cap.spendTrackerAlias - additionalProperties = cap.additionalProperties.toMutableMap() - } - - /** - * Accumulated spend ceiling above which the discount stops applying. - */ - 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 } - - /** Alias of the spend tracker this cap is measured against. */ - fun spendTrackerAlias(spendTrackerAlias: String) = - spendTrackerAlias(JsonField.of(spendTrackerAlias)) - - /** - * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. - * - * You should usually call [Builder.spendTrackerAlias] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { - this.spendTrackerAlias = spendTrackerAlias - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Cap]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .amount() - * .spendTrackerAlias() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Cap = - Cap( - checkRequired("amount", amount), - checkRequired("spendTrackerAlias", spendTrackerAlias), - 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 MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Cap = apply { - if (validated) { - return@apply - } - - amount() - spendTrackerAlias() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a 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 (spendTrackerAlias.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cap && - amount == other.amount && - spendTrackerAlias == other.spendTrackerAlias && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, spendTrackerAlias, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" - } + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is DiscountConfiguration && - cap == other.cap && - paymentFraction == other.paymentFraction && + return other is InvoiceAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(cap, paymentFraction, additionalProperties) + Objects.hash(quantity, unitPrice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" + "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class ThresholdBalanceSpecifier + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val exclude: JsonField>, + private val access: JsonField, + private val invoice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("exclude") + @JsonProperty("access") @ExcludeMissing - exclude: JsonField> = JsonMissing.of() - ) : this(exclude, mutableMapOf()) + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun exclude(): List = exclude.getRequired("exclude") + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [exclude]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * Unlike [exclude], this method doesn't throw if the JSON field has an + * Unlike [access], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("exclude") + @JsonProperty("access") @ExcludeMissing - fun _exclude(): JsonField> = exclude + fun _access(): JsonField = access + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -29222,57 +33497,48 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ThresholdBalanceSpecifier]. - * - * The following fields are required: - * ```java - * .exclude() - * ``` + * [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [ThresholdBalanceSpecifier]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var exclude: JsonField>? = null + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = - apply { - exclude = - thresholdBalanceSpecifier.exclude.map { it.toMutableList() } - additionalProperties = - thresholdBalanceSpecifier.additionalProperties.toMutableMap() - } + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() + } - fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + fun access(access: Access) = access(JsonField.of(access)) /** - * Sets [Builder.exclude] to an arbitrary JSON value. + * Sets [Builder.access] to an arbitrary JSON value. * - * You should usually call [Builder.exclude] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun exclude(exclude: JsonField>) = apply { - this.exclude = exclude.map { it.toMutableList() } - } + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) /** - * Adds a single [Exclude] to [Builder.exclude]. + * Sets [Builder.invoice] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.invoice] with a well-typed [Invoice] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addExclude(exclude: Exclude) = apply { - this.exclude = - (this.exclude ?: JsonField.of(mutableListOf())).also { - checkKnown("exclude", it).add(exclude) - } - } + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } fun additionalProperties(additionalProperties: Map) = apply { @@ -29297,22 +33563,12 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdBalanceSpecifier]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .exclude() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ThresholdBalanceSpecifier = - ThresholdBalanceSpecifier( - checkRequired("exclude", exclude).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -29327,12 +33583,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): ThresholdBalanceSpecifier = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - exclude().forEach { it.validate() } + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -29352,41 +33609,65 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - class Exclude + class Access @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val customFieldFilters: JsonField>, + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - customFieldFilters: JsonField> = - JsonMissing.of() - ) : this(customFieldFilters, mutableMapOf()) + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded * with an unexpected value). */ - fun customFieldFilters(): List = - customFieldFilters.getRequired("custom_field_filters") + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Returns the raw JSON value of [customFieldFilters]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. * - * Unlike [customFieldFilters], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - fun _customFieldFilters(): JsonField> = - customFieldFilters + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -29403,61 +33684,63 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Exclude]. + * Returns a mutable builder for constructing an instance of [Access]. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Exclude]. */ + /** A builder for [Access]. */ class Builder internal constructor() { - private var customFieldFilters: - JsonField>? = - null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(exclude: Exclude) = apply { - customFieldFilters = - exclude.customFieldFilters.map { it.toMutableList() } - additionalProperties = exclude.additionalProperties.toMutableMap() + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() } - fun customFieldFilters(customFieldFilters: List) = - customFieldFilters(JsonField.of(customFieldFilters)) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.customFieldFilters] with a - * well-typed `List` value instead. This method is - * primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun customFieldFilters( - customFieldFilters: JsonField> - ) = apply { - this.customFieldFilters = - customFieldFilters.map { it.toMutableList() } + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + /** - * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { - customFieldFilters = - (customFieldFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("customFieldFilters", it).add(customFieldFilter) - } + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = @@ -29483,23 +33766,23 @@ private constructor( } /** - * Returns an immutable instance of [Exclude]. + * Returns an immutable instance of [Access]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Exclude = - Exclude( - checkRequired("customFieldFilters", customFieldFilters).map { - it.toImmutable() - }, + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -29516,12 +33799,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Exclude = apply { + fun validate(): Access = apply { if (validated) { return@apply } - customFieldFilters().forEach { it.validate() } + decimalPlaces() + roundingMethod().validate() validated = true } @@ -29541,434 +33825,558 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (customFieldFilters.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - class CustomFieldFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val entity: JsonField, - private val key: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JsonCreator - private constructor( - @JsonProperty("entity") - @ExcludeMissing - entity: JsonField = JsonMissing.of(), - @JsonProperty("key") - @ExcludeMissing - key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(entity, key, value, mutableMapOf()) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun entity(): Entity = entity.getRequired("entity") + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. */ - fun key(): String = key.getRequired("key") + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } /** - * @throws MetronomeInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. */ - fun value(): String = value.getRequired("value") + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } /** - * Returns the raw JSON value of [entity]. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. * - * Unlike [entity], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. */ - @JsonProperty("entity") - @ExcludeMissing - fun _entity(): JsonField = entity + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [key]. + * Validates that the types of all values in this object match their + * expected types recursively. * - * Unlike [key], this method doesn't throw if the JSON field has an - * unexpected type. + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. */ - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [value]. + * Returns a score indicating how many valid values are contained in + * this object recursively. * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is RoundingMethod && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - /** - * Returns a mutable builder for constructing an instance of - * [CustomFieldFilter]. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [CustomFieldFilter]. */ - class Builder internal constructor() { + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } - private var entity: JsonField? = null - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - @JvmSynthetic - internal fun from(customFieldFilter: CustomFieldFilter) = apply { - entity = customFieldFilter.entity - key = customFieldFilter.key - value = customFieldFilter.value - additionalProperties = - customFieldFilter.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun entity(entity: Entity) = entity(JsonField.of(entity)) + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.entity] to an arbitrary JSON value. - * - * You should usually call [Builder.entity] with a well-typed - * [Entity] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun entity(entity: JsonField) = apply { - this.entity = entity - } + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - fun key(key: String) = key(JsonField.of(key)) + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - /** - * Sets [Builder.key] to an arbitrary JSON value. - * - * You should usually call [Builder.key] with a well-typed [String] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun key(key: JsonField) = apply { this.key = key } + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - fun value(value: String) = value(JsonField.of(value)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [CustomFieldFilter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CustomFieldFilter = - CustomFieldFilter( - checkRequired("entity", entity), - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Validates that the types of all values in this object match their - * expected types recursively. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API - * for existing fields. + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this - * object doesn't match its expected type. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun validate(): CustomFieldFilter = apply { - if (validated) { - return@apply + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - entity().validate() - key() - value() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in - * this object recursively. + * Returns an immutable instance of [Invoice]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (entity.asKnown().getOrNull()?.validity() ?: 0) + - (if (key.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - class Entity - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var validated: Boolean = false - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized - * from data that doesn't match any known member, and you want to - * know that value. For example, if the SDK is on an older version - * than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } - companion object { + decimalPlaces() + roundingMethod().validate() + validated = true + } - @JvmField val COMMIT = of("Commit") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val CONTRACT_CREDIT = of("ContractCredit") + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - @JvmField - val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** An enum containing [Entity]'s known values. */ - enum class Known { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - } + companion object { - /** - * An enum containing [Entity]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Entity] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known - * member. For example, if the SDK is on an older version than the - * API, then the API may respond with new members that the SDK is - * unaware of. - * - It was constructed with an arbitrary value using the [of] - * method. - */ - enum class Value { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - /** - * An enum member indicating that [Entity] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns an enum member corresponding to this class instance's - * value, or [Value._UNKNOWN] if the class was instantiated with an - * unknown value. - * - * Use the [known] method instead if you're certain the value is - * always known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT -> Value.COMMIT - CONTRACT_CREDIT -> Value.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT - else -> Value._UNKNOWN - } + @JvmField val FLOOR = of("FLOOR") - /** - * Returns an enum member corresponding to this class instance's - * value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's - * value is a not a known member. - */ - fun known(): Known = - when (this) { - COMMIT -> Known.COMMIT - CONTRACT_CREDIT -> Known.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT - else -> - throw MetronomeInvalidDataException( - "Unknown Entity: $value" - ) - } + @JvmField val CEILING = of("CEILING") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's - * value does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the - * API for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this - * object doesn't match its expected type. + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. */ - fun validate(): Entity = apply { - if (validated) { - return@apply - } + _UNKNOWN, + } - known() - validated = true + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - return other is Entity && value == other.value + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - override fun hashCode() = value.hashCode() + private var validated: Boolean = false - override fun toString() = value.toString() + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CustomFieldFilter && - entity == other.entity && - key == other.key && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(entity, key, value, additionalProperties) + return other is RoundingMethod && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -29976,19 +34384,20 @@ private constructor( return true } - return other is Exclude && - customFieldFilters == other.customFieldFilters && + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(customFieldFilters, additionalProperties) + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -29996,19 +34405,165 @@ private constructor( return true } - return other is ThresholdBalanceSpecifier && - exclude == other.exclude && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(exclude, additionalProperties) + Objects.hash(access, invoice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + class RateType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + LIST_RATE, + COMMIT_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST_RATE, + COMMIT_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -30016,28 +34571,24 @@ private constructor( return true } - return other is UpdatePrepaidBalanceThresholdConfiguration && - commit == other.commit && - customCreditTypeId == other.customCreditTypeId && - discountConfiguration == other.discountConfiguration && - isEnabled == other.isEnabled && - paymentGateConfig == other.paymentGateConfig && - rechargeToAmount == other.rechargeToAmount && - thresholdAmount == other.thresholdAmount && - thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && + return other is UpdateRecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + endingBefore == other.endingBefore && + invoiceAmount == other.invoiceAmount && + prorationRounding == other.prorationRounding && + rateType == other.rateType && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + id, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties, ) } @@ -30045,16 +34596,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" + "UpdateRecurringCommit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } - class UpdateRecurringCommit + class UpdateRecurringCredit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val accessAmount: JsonField, private val endingBefore: JsonField, - private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val additionalProperties: MutableMap, ) { @@ -30068,13 +34619,20 @@ private constructor( @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - invoiceAmount: JsonField = JsonMissing.of(), + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), - ) : this(id, accessAmount, endingBefore, invoiceAmount, rateType, mutableMapOf()) + ) : this( + id, + accessAmount, + endingBefore, + prorationRounding, + rateType, + mutableMapOf(), + ) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or @@ -30098,11 +34656,13 @@ private constructor( endingBefore.getOptional("ending_before") /** + * Rounding configuration for prorated recurring credit amounts. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun invoiceAmount(): Optional = - invoiceAmount.getOptional("invoice_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type @@ -30138,14 +34698,14 @@ private constructor( fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [invoiceAmount]. + * Returns the raw JSON value of [prorationRounding]. * - * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _invoiceAmount(): JsonField = invoiceAmount + fun _prorationRounding(): JsonField = prorationRounding /** * Returns the raw JSON value of [rateType]. @@ -30173,7 +34733,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UpdateRecurringCommit]. + * [UpdateRecurringCredit]. * * The following fields are required: * ```java @@ -30183,25 +34743,25 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UpdateRecurringCommit]. */ + /** A builder for [UpdateRecurringCredit]. */ class Builder internal constructor() { private var id: JsonField? = null private var accessAmount: JsonField = JsonMissing.of() private var endingBefore: JsonField = JsonMissing.of() - private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { - id = updateRecurringCommit.id - accessAmount = updateRecurringCommit.accessAmount - endingBefore = updateRecurringCommit.endingBefore - invoiceAmount = updateRecurringCommit.invoiceAmount - rateType = updateRecurringCommit.rateType + internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { + id = updateRecurringCredit.id + accessAmount = updateRecurringCredit.accessAmount + endingBefore = updateRecurringCredit.endingBefore + prorationRounding = updateRecurringCredit.prorationRounding + rateType = updateRecurringCredit.rateType additionalProperties = - updateRecurringCommit.additionalProperties.toMutableMap() + updateRecurringCredit.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -30243,18 +34803,26 @@ private constructor( this.endingBefore = endingBefore } - fun invoiceAmount(invoiceAmount: InvoiceAmount) = - invoiceAmount(JsonField.of(invoiceAmount)) + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Sets [Builder.invoiceAmount] to an arbitrary JSON value. + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceAmount] with a well-typed - * [InvoiceAmount] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun invoiceAmount(invoiceAmount: JsonField) = apply { - this.invoiceAmount = invoiceAmount + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -30291,7 +34859,7 @@ private constructor( } /** - * Returns an immutable instance of [UpdateRecurringCommit]. + * Returns an immutable instance of [UpdateRecurringCredit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30302,12 +34870,12 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdateRecurringCommit = - UpdateRecurringCommit( + fun build(): UpdateRecurringCredit = + UpdateRecurringCredit( checkRequired("id", id), accessAmount, endingBefore, - invoiceAmount, + prorationRounding, rateType, additionalProperties.toMutableMap(), ) @@ -30325,7 +34893,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): UpdateRecurringCommit = apply { + fun validate(): UpdateRecurringCredit = apply { if (validated) { return@apply } @@ -30333,7 +34901,7 @@ private constructor( id() accessAmount().ifPresent { it.validate() } endingBefore() - invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } validated = true } @@ -30357,7 +34925,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + - (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) class AccessAmount @@ -30564,55 +35132,36 @@ private constructor( "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class InvoiceAmount + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonProperty("access") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [access]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * Unlike [access], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("access") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -30630,239 +35179,67 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [InvoiceAmount]. + * [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoiceAmount]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var access: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(invoiceAmount: InvoiceAmount) = apply { - quantity = invoiceAmount.quantity - unitPrice = invoiceAmount.unitPrice - additionalProperties = invoiceAmount.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } - - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InvoiceAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InvoiceAmount = - InvoiceAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): InvoiceAmount = apply { - if (validated) { - return@apply - } - - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = + prorationRounding.additionalProperties.toMutableMap() } - return other is InvoiceAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } - - class RateType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } - - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST_RATE, - COMMIT_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an - * unknown value. + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -30875,12 +35252,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } validated = true } @@ -30899,526 +35276,418 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UpdateRecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - endingBefore == other.endingBefore && - invoiceAmount == other.invoiceAmount && - rateType == other.rateType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - endingBefore, - invoiceAmount, - rateType, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UpdateRecurringCommit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, rateType=$rateType, additionalProperties=$additionalProperties}" - } - - class UpdateRecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val endingBefore: JsonField, - private val rateType: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - ) : this(id, accessAmount, endingBefore, rateType, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accessAmount(): Optional = - accessAmount.getOptional("access_amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount - - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - fun toBuilder() = Builder().from(this) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** - * Returns a mutable builder for constructing an instance of - * [UpdateRecurringCredit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** A builder for [UpdateRecurringCredit]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - private var id: JsonField? = null - private var accessAmount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmSynthetic - internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { - id = updateRecurringCredit.id - accessAmount = updateRecurringCredit.accessAmount - endingBefore = updateRecurringCredit.endingBefore - rateType = updateRecurringCredit.rateType - additionalProperties = - updateRecurringCredit.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun id(id: String) = id(JsonField.of(id)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + companion object { - fun accessAmount(accessAmount: AccessAmount) = - accessAmount(JsonField.of(accessAmount)) + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed - * [AccessAmount] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } + /** A builder for [Access]. */ + class Builder internal constructor() { - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., + * -2 rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an immutable instance of [UpdateRecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateRecurringCredit = - UpdateRecurringCredit( - checkRequired("id", id), - accessAmount, - endingBefore, - rateType, - additionalProperties.toMutableMap(), - ) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): UpdateRecurringCredit = apply { - if (validated) { - return@apply - } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - id() - accessAmount().ifPresent { it.validate() } - endingBefore() - rateType().ifPresent { it.validate() } - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + decimalPlaces() + roundingMethod().validate() + validated = true + } - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + companion object { - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JvmField val FLOOR = of("FLOOR") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val CEILING = of("CEILING") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic + fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - fun toBuilder() = Builder().from(this) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - companion object { + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - /** - * Returns a mutable builder for constructing an instance of [AccessAmount]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - quantity = accessAmount.quantity - unitPrice = accessAmount.unitPrice - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } + private var validated: Boolean = false - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } + known() + validated = true + } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessAmount = - AccessAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply - } + override fun hashCode(): Int = hashCode - quantity() - unitPrice() - validated = true + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && + return other is ProrationRounding && + access == other.access && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } class RateType @@ -31575,18 +35844,26 @@ private constructor( id == other.id && accessAmount == other.accessAmount && endingBefore == other.endingBefore && + prorationRounding == other.prorationRounding && rateType == other.rateType && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, accessAmount, endingBefore, rateType, additionalProperties) + Objects.hash( + id, + accessAmount, + endingBefore, + prorationRounding, + rateType, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "UpdateRecurringCredit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, rateType=$rateType, additionalProperties=$additionalProperties}" + "UpdateRecurringCredit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } class UpdateRefundInvoice diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponse.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponse.kt index 8fe88304..508c628e 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponse.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponse.kt @@ -6048,6 +6048,7 @@ private constructor( class OverrideSpecifier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anyCommitOrCreditIds: JsonField>, private val billingFrequency: JsonField, private val commitIds: JsonField>, private val presentationGroupValues: JsonField, @@ -6060,6 +6061,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + anyCommitOrCreditIds: JsonField> = JsonMissing.of(), @JsonProperty("billing_frequency") @ExcludeMissing billingFrequency: JsonField = JsonMissing.of(), @@ -6082,6 +6086,7 @@ private constructor( @ExcludeMissing recurringCommitIds: JsonField> = JsonMissing.of(), ) : this( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -6092,6 +6097,13 @@ private constructor( mutableMapOf(), ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun anyCommitOrCreditIds(): Optional> = + anyCommitOrCreditIds.getOptional("any_commit_or_credit_ids") + /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -6138,6 +6150,16 @@ private constructor( fun recurringCommitIds(): Optional> = recurringCommitIds.getOptional("recurring_commit_ids") + /** + * Returns the raw JSON value of [anyCommitOrCreditIds]. + * + * Unlike [anyCommitOrCreditIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("any_commit_or_credit_ids") + @ExcludeMissing + fun _anyCommitOrCreditIds(): JsonField> = anyCommitOrCreditIds + /** * Returns the raw JSON value of [billingFrequency]. * @@ -6233,6 +6255,7 @@ private constructor( /** A builder for [OverrideSpecifier]. */ class Builder internal constructor() { + private var anyCommitOrCreditIds: JsonField>? = null private var billingFrequency: JsonField = JsonMissing.of() private var commitIds: JsonField>? = null private var presentationGroupValues: JsonField = @@ -6245,6 +6268,8 @@ private constructor( @JvmSynthetic internal fun from(overrideSpecifier: OverrideSpecifier) = apply { + anyCommitOrCreditIds = + overrideSpecifier.anyCommitOrCreditIds.map { it.toMutableList() } billingFrequency = overrideSpecifier.billingFrequency commitIds = overrideSpecifier.commitIds.map { it.toMutableList() } presentationGroupValues = overrideSpecifier.presentationGroupValues @@ -6256,6 +6281,34 @@ private constructor( additionalProperties = overrideSpecifier.additionalProperties.toMutableMap() } + fun anyCommitOrCreditIds(anyCommitOrCreditIds: List) = + anyCommitOrCreditIds(JsonField.of(anyCommitOrCreditIds)) + + /** + * Sets [Builder.anyCommitOrCreditIds] to an arbitrary JSON value. + * + * You should usually call [Builder.anyCommitOrCreditIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun anyCommitOrCreditIds(anyCommitOrCreditIds: JsonField>) = + apply { + this.anyCommitOrCreditIds = + anyCommitOrCreditIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [anyCommitOrCreditIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAnyCommitOrCreditId(anyCommitOrCreditId: String) = apply { + anyCommitOrCreditIds = + (anyCommitOrCreditIds ?: JsonField.of(mutableListOf())).also { + checkKnown("anyCommitOrCreditIds", it).add(anyCommitOrCreditId) + } + } + fun billingFrequency(billingFrequency: BillingFrequency) = billingFrequency(JsonField.of(billingFrequency)) @@ -6418,6 +6471,7 @@ private constructor( */ fun build(): OverrideSpecifier = OverrideSpecifier( + (anyCommitOrCreditIds ?: JsonMissing.of()).map { it.toImmutable() }, billingFrequency, (commitIds ?: JsonMissing.of()).map { it.toImmutable() }, presentationGroupValues, @@ -6446,6 +6500,7 @@ private constructor( return@apply } + anyCommitOrCreditIds() billingFrequency().ifPresent { it.validate() } commitIds() presentationGroupValues().ifPresent { it.validate() } @@ -6472,7 +6527,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (anyCommitOrCreditIds.asKnown().getOrNull()?.size ?: 0) + + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + (commitIds.asKnown().getOrNull()?.size ?: 0) + (presentationGroupValues.asKnown().getOrNull()?.validity() ?: 0) + (pricingGroupValues.asKnown().getOrNull()?.validity() ?: 0) + @@ -6892,6 +6948,7 @@ private constructor( } return other is OverrideSpecifier && + anyCommitOrCreditIds == other.anyCommitOrCreditIds && billingFrequency == other.billingFrequency && commitIds == other.commitIds && presentationGroupValues == other.presentationGroupValues && @@ -6904,6 +6961,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + anyCommitOrCreditIds, billingFrequency, commitIds, presentationGroupValues, @@ -6918,7 +6976,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OverrideSpecifier{billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" + "OverrideSpecifier{anyCommitOrCreditIds=$anyCommitOrCreditIds, billingFrequency=$billingFrequency, commitIds=$commitIds, presentationGroupValues=$presentationGroupValues, pricingGroupValues=$pricingGroupValues, productId=$productId, productTags=$productTags, recurringCommitIds=$recurringCommitIds, additionalProperties=$additionalProperties}" } class OverwriteRate @@ -8456,6 +8514,7 @@ private constructor( private val name: JsonField, private val netsuiteSalesOrderId: JsonField, private val proration: JsonField, + private val prorationRounding: JsonField, private val recurrenceFrequency: JsonField, private val rolloverFraction: JsonField, private val specifiers: JsonField>, @@ -8512,6 +8571,9 @@ private constructor( @JsonProperty("proration") @ExcludeMissing proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("recurrence_frequency") @ExcludeMissing recurrenceFrequency: JsonField = JsonMissing.of(), @@ -8542,6 +8604,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -8692,6 +8755,15 @@ private constructor( */ fun proration(): Optional = proration.getOptional("proration") + /** + * Rounding configuration for prorated recurring commit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + /** * The frequency at which the recurring commits will be created. If not provided: - The * commits will be created on the usage invoice frequency. If provided: - The period @@ -8894,6 +8966,16 @@ private constructor( @ExcludeMissing fun _proration(): JsonField = proration + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + /** * Returns the raw JSON value of [recurrenceFrequency]. * @@ -8987,6 +9069,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var netsuiteSalesOrderId: JsonField = JsonMissing.of() private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var recurrenceFrequency: JsonField = JsonMissing.of() private var rolloverFraction: JsonField = JsonMissing.of() private var specifiers: JsonField>? = null @@ -9015,6 +9098,7 @@ private constructor( name = addRecurringCommit.name netsuiteSalesOrderId = addRecurringCommit.netsuiteSalesOrderId proration = addRecurringCommit.proration + prorationRounding = addRecurringCommit.prorationRounding recurrenceFrequency = addRecurringCommit.recurrenceFrequency rolloverFraction = addRecurringCommit.rolloverFraction specifiers = addRecurringCommit.specifiers.map { it.toMutableList() } @@ -9280,6 +9364,28 @@ private constructor( this.proration = proration } + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + /** * The frequency at which the recurring commits will be created. If not provided: - * The commits will be created on the usage invoice frequency. If provided: - The @@ -9426,6 +9532,7 @@ private constructor( name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, @@ -9468,6 +9575,7 @@ private constructor( name() netsuiteSalesOrderId() proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } recurrenceFrequency().ifPresent { it.validate() } rolloverFraction() specifiers().ifPresent { it.forEach { it.validate() } } @@ -9508,6 +9616,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -11062,121 +11171,143 @@ private constructor( override fun toString() = value.toString() } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val invoice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Unlike [access], this method doesn't throw if the JSON field has an unexpected + * type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access - companion object { + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice") + @ExcludeMissing + fun _invoice(): JsonField = invoice - @JvmField val MONTHLY = of("MONTHLY") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val QUARTERLY = of("QUARTERLY") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val ANNUAL = of("ANNUAL") + fun toBuilder() = Builder().from(this) - @JvmField val WEEKLY = of("WEEKLY") + companion object { - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + /** + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) - /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun access(access: JsonField) = apply { this.access = access } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -11189,12 +11320,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): RecurrenceFrequency = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -11212,27 +11344,4146 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is RecurrenceFrequency && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - override fun toString() = value.toString() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddRecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + commitDuration == other.commitDuration && + priority == other.priority && + product == other.product && + rateType == other.rateType && + startingAt == other.startingAt && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + contract == other.contract && + description == other.description && + endingBefore == other.endingBefore && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceAmount == other.invoiceAmount && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + proration == other.proration && + prorationRounding == other.prorationRounding && + recurrenceFrequency == other.recurrenceFrequency && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + subscriptionConfig == other.subscriptionConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAt, + applicableProductIds, + applicableProductTags, + contract, + description, + endingBefore, + hierarchyConfiguration, + invoiceAmount, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddRecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + } + + class AddRecurringCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessAmount: JsonField, + private val commitDuration: JsonField, + private val priority: JsonField, + private val product: JsonField, + private val rateType: JsonField, + private val startingAt: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val contract: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val proration: JsonField, + private val prorationRounding: JsonField, + private val recurrenceFrequency: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val subscriptionConfig: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") + @ExcludeMissing + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("commit_duration") + @ExcludeMissing + commitDuration: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("contract") + @ExcludeMissing + contract: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") + @ExcludeMissing + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("recurrence_frequency") + @ExcludeMissing + recurrenceFrequency: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + @JsonProperty("subscription_config") + @ExcludeMissing + subscriptionConfig: JsonField = JsonMissing.of(), + ) : this( + id, + accessAmount, + commitDuration, + priority, + product, + rateType, + startingAt, + applicableProductIds, + applicableProductTags, + contract, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + specifiers, + subscriptionConfig, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of commit to grant. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") + + /** + * The amount of time the created commits will be valid for + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priority(): Double = priority.getRequired("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun product(): Product = product.getRequired("product") + + /** + * Whether the created commits will use the commit rate or list rate + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun rateType(): RateType = rateType.getRequired("rate_type") + + /** + * Determines the start time for the first commit + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun contract(): Optional = contract.getOptional("contract") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Determines when the contract will stop creating recurring commits. Optional + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * Optional configuration for recurring credit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") + + /** + * Displayed on invoices. Will be passed through to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Will be passed down to the individual commits + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun proration(): Optional = proration.getOptional("proration") + + /** + * Rounding configuration for prorated recurring credit amounts. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun recurrenceFrequency(): Optional = + recurrenceFrequency.getOptional("recurrence_frequency") + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be between + * 0 and 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = specifiers.getOptional("specifiers") + + /** + * Attach a subscription to the recurring commit/credit. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun subscriptionConfig(): Optional = + subscriptionConfig.getOptional("subscription_config") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [accessAmount]. + * + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access_amount") + @ExcludeMissing + fun _accessAmount(): JsonField = accessAmount + + /** + * Returns the raw JSON value of [commitDuration]. + * + * Unlike [commitDuration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("commit_duration") + @ExcludeMissing + fun _commitDuration(): JsonField = commitDuration + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags + + /** + * Returns the raw JSON value of [contract]. + * + * Unlike [contract], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("contract") + @ExcludeMissing + fun _contract(): JsonField = contract + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore + + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration + + /** + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("proration_rounding") + @ExcludeMissing + fun _prorationRounding(): JsonField = prorationRounding + + /** + * Returns the raw JSON value of [recurrenceFrequency]. + * + * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recurrence_frequency") + @ExcludeMissing + fun _recurrenceFrequency(): JsonField = recurrenceFrequency + + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers + + /** + * Returns the raw JSON value of [subscriptionConfig]. + * + * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_config") + @ExcludeMissing + fun _subscriptionConfig(): JsonField = + subscriptionConfig + + @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 [AddRecurringCredit]. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddRecurringCredit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accessAmount: JsonField? = null + private var commitDuration: JsonField? = null + private var priority: JsonField? = null + private var product: JsonField? = null + private var rateType: JsonField? = null + private var startingAt: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var contract: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var proration: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var recurrenceFrequency: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var subscriptionConfig: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addRecurringCredit: AddRecurringCredit) = apply { + id = addRecurringCredit.id + accessAmount = addRecurringCredit.accessAmount + commitDuration = addRecurringCredit.commitDuration + priority = addRecurringCredit.priority + product = addRecurringCredit.product + rateType = addRecurringCredit.rateType + startingAt = addRecurringCredit.startingAt + applicableProductIds = + addRecurringCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addRecurringCredit.applicableProductTags.map { it.toMutableList() } + contract = addRecurringCredit.contract + description = addRecurringCredit.description + endingBefore = addRecurringCredit.endingBefore + hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration + name = addRecurringCredit.name + netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId + proration = addRecurringCredit.proration + prorationRounding = addRecurringCredit.prorationRounding + recurrenceFrequency = addRecurringCredit.recurrenceFrequency + rolloverFraction = addRecurringCredit.rolloverFraction + specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } + subscriptionConfig = addRecurringCredit.subscriptionConfig + additionalProperties = addRecurringCredit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of commit to grant. */ + fun accessAmount(accessAmount: AccessAmount) = + accessAmount(JsonField.of(accessAmount)) + + /** + * Sets [Builder.accessAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount + } + + /** The amount of time the created commits will be valid for */ + fun commitDuration(commitDuration: CommitDuration) = + commitDuration(JsonField.of(commitDuration)) + + /** + * Sets [Builder.commitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.commitDuration] with a well-typed + * [CommitDuration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun commitDuration(commitDuration: JsonField) = apply { + this.commitDuration = commitDuration + } + + /** Will be passed down to the individual commits */ + fun priority(priority: Double) = priority(JsonField.of(priority)) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + fun product(product: Product) = product(JsonField.of(product)) + + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun product(product: JsonField) = apply { this.product = product } + + /** Whether the created commits will use the commit rate or list rate */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + + /** Determines the start time for the first commit */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + /** Will be passed down to the individual commits */ + fun applicableProductIds(applicableProductIds: List) = + applicableProductIds(JsonField.of(applicableProductIds)) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** Will be passed down to the individual commits */ + fun applicableProductTags(applicableProductTags: List) = + applicableProductTags(JsonField.of(applicableProductTags)) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + fun contract(contract: Contract) = contract(JsonField.of(contract)) + + /** + * Sets [Builder.contract] to an arbitrary JSON value. + * + * You should usually call [Builder.contract] with a well-typed [Contract] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun contract(contract: JsonField) = apply { this.contract = contract } + + /** Will be passed down to the individual commits */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Determines when the contract will stop creating recurring commits. Optional */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + /** Optional configuration for recurring credit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } + + /** Displayed on invoices. Will be passed through to the individual commits */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Will be passed down to the individual commits */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, + * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + fun proration(proration: Proration) = proration(JsonField.of(proration)) + + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun proration(proration: JsonField) = apply { + this.proration = proration + } + + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) + + /** + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. + * + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - + * The commits will be created on the usage invoice frequency. If provided: - The + * period defined in the duration will correspond to this frequency. - Commits will + * be created aligned with the recurring commit's starting_at rather than the usage + * invoice dates. + */ + fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = + recurrenceFrequency(JsonField.of(recurrenceFrequency)) + + /** + * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.recurrenceFrequency] with a well-typed + * [RecurrenceFrequency] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recurrenceFrequency(recurrenceFrequency: JsonField) = + apply { + this.recurrenceFrequency = recurrenceFrequency + } + + /** + * Will be passed down to the individual commits. This controls how much of an + * individual unexpired commit will roll over upon contract transition. Must be + * between 0 and 1. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(JsonField.of(rolloverFraction)) + + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. + */ + fun specifiers(specifiers: List) = + specifiers(JsonField.of(specifiers)) + + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } + + /** + * Adds a single [CommitSpecifier] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifier) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } + + /** Attach a subscription to the recurring commit/credit. */ + fun subscriptionConfig(subscriptionConfig: RecurringCommitSubscriptionConfig) = + subscriptionConfig(JsonField.of(subscriptionConfig)) + + /** + * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionConfig] with a well-typed + * [RecurringCommitSubscriptionConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun subscriptionConfig( + subscriptionConfig: JsonField + ) = apply { this.subscriptionConfig = subscriptionConfig } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AddRecurringCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accessAmount() + * .commitDuration() + * .priority() + * .product() + * .rateType() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddRecurringCredit = + AddRecurringCredit( + checkRequired("id", id), + checkRequired("accessAmount", accessAmount), + checkRequired("commitDuration", commitDuration), + checkRequired("priority", priority), + checkRequired("product", product), + checkRequired("rateType", rateType), + checkRequired("startingAt", startingAt), + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + contract, + description, + endingBefore, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + proration, + prorationRounding, + recurrenceFrequency, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + subscriptionConfig, + 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 MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AddRecurringCredit = apply { + if (validated) { + return@apply + } + + id() + accessAmount().validate() + commitDuration().validate() + priority() + product().validate() + rateType().validate() + startingAt() + applicableProductIds() + applicableProductTags() + contract().ifPresent { it.validate() } + description() + endingBefore() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + proration().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + recurrenceFrequency().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + subscriptionConfig().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (contract.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) + + /** The amount of commit to grant. */ + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val unitPrice: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): Double = unitPrice.getRequired("unit_price") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + + @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 [AccessAmount]. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField? = null + private var unitPrice: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + creditTypeId = accessAmount.creditTypeId + unitPrice = accessAmount.unitPrice + quantity = accessAmount.quantity + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } + + fun creditTypeId(creditTypeId: String) = + creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditTypeId() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccessAmount = + AccessAmount( + checkRequired("creditTypeId", creditTypeId), + checkRequired("unitPrice", unitPrice), + quantity, + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): AccessAmount = apply { + if (validated) { + return@apply + } + + creditTypeId() + unitPrice() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessAmount && + creditTypeId == other.creditTypeId && + unitPrice == other.unitPrice && + quantity == other.quantity && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + /** The amount of time the created commits will be valid for */ + class CommitDuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val unit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), + ) : this(value, unit, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun value(): Double = value.getRequired("value") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + @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 [CommitDuration]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitDuration]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var unit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitDuration: CommitDuration) = apply { + value = commitDuration.value + unit = commitDuration.unit + additionalProperties = commitDuration.additionalProperties.toMutableMap() + } + + fun value(value: Double) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun unit(unit: Unit) = unit(JsonField.of(unit)) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [Unit] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitDuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitDuration = + CommitDuration( + checkRequired("value", value), + unit, + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CommitDuration = apply { + if (validated) { + return@apply + } + + value() + unit().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (value.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + class Unit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERIODS = of("PERIODS") + + @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) + } + + /** An enum containing [Unit]'s known values. */ + enum class Known { + PERIODS + } + + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERIODS, + /** + * An enum member indicating that [Unit] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERIODS -> Value.PERIODS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + PERIODS -> Known.PERIODS + else -> throw MetronomeInvalidDataException("Unknown Unit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitDuration && + value == other.value && + unit == other.unit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(value, unit, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + } + + class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Product]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Product]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Product = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + /** Whether the created commits will use the commit rate or list rate */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Contract + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Contract]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Contract]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contract: Contract) = apply { + id = contract.id + additionalProperties = contract.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Contract]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Contract = + Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Contract = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Contract && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Contract{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * Determines whether the first and last commit will be prorated. If not provided, the + * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). + */ + class Proration @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("NONE") + + @JvmField val FIRST = of("FIRST") + + @JvmField val LAST = of("LAST") + + @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + + @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) + } + + /** An enum containing [Proration]'s known values. */ + enum class Known { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + } + + /** + * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Proration] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + FIRST, + LAST, + FIRST_AND_LAST, + /** + * An enum member indicating that [Proration] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + FIRST -> Value.FIRST + LAST -> Value.LAST + FIRST_AND_LAST -> Value.FIRST_AND_LAST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + FIRST -> Known.FIRST + LAST -> Known.LAST + FIRST_AND_LAST -> Known.FIRST_AND_LAST + else -> throw MetronomeInvalidDataException("Unknown Proration: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Proration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Proration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val access: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access") + @ExcludeMissing + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun access(): Optional = access.getOptional("access") + + /** + * Returns the raw JSON value of [access]. + * + * Unlike [access], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + @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 + * [ProrationRounding]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } + + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ProrationRounding = apply { + if (validated) { + return@apply + } + + access().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) + + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) + + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod + + @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 [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Access]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } + + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) + + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } + + decimalPlaces() + roundingMethod().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoundingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProrationRounding && + access == other.access && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" + } + + /** + * The frequency at which the recurring commits will be created. If not provided: - The + * commits will be created on the usage invoice frequency. If provided: - The period + * defined in the duration will correspond to this frequency. - Commits will be created + * aligned with the recurring commit's starting_at rather than the usage invoice dates. + */ + class RecurrenceFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val WEEKLY = of("WEEKLY") + + @JvmField val DAILY = of("DAILY") + + @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + } + + /** An enum containing [RecurrenceFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + } + + /** + * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + DAILY, + /** + * An enum member indicating that [RecurrenceFrequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + DAILY -> Value.DAILY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + DAILY -> Known.DAILY + else -> + throw MetronomeInvalidDataException( + "Unknown RecurrenceFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RecurrenceFrequency = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecurrenceFrequency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddRecurringCommit && + return other is AddRecurringCredit && id == other.id && accessAmount == other.accessAmount && commitDuration == other.commitDuration && @@ -11246,10 +15497,10 @@ private constructor( description == other.description && endingBefore == other.endingBefore && hierarchyConfiguration == other.hierarchyConfiguration && - invoiceAmount == other.invoiceAmount && name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && proration == other.proration && + prorationRounding == other.prorationRounding && recurrenceFrequency == other.recurrenceFrequency && rolloverFraction == other.rolloverFraction && specifiers == other.specifiers && @@ -11272,10 +15523,10 @@ private constructor( description, endingBefore, hierarchyConfiguration, - invoiceAmount, name, netsuiteSalesOrderId, proration, + prorationRounding, recurrenceFrequency, rolloverFraction, specifiers, @@ -11287,114 +15538,83 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddRecurringCommit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, invoiceAmount=$invoiceAmount, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" + "AddRecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, prorationRounding=$prorationRounding, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" } - class AddRecurringCredit + class AddResellerRoyalty @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val commitDuration: JsonField, - private val priority: JsonField, - private val product: JsonField, - private val rateType: JsonField, - private val startingAt: JsonField, + private val resellerType: JsonField, private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val contract: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val hierarchyConfiguration: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val proration: JsonField, - private val recurrenceFrequency: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val subscriptionConfig: JsonField, + private val applicableProductTags: JsonField>, + private val awsAccountNumber: JsonField, + private val awsOfferId: JsonField, + private val awsPayerReferenceId: JsonField, + private val endingBefore: JsonField, + private val fraction: JsonField, + private val gcpAccountId: JsonField, + private val gcpOfferId: JsonField, + private val netsuiteResellerId: JsonField, + private val resellerContractValue: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("commit_duration") - @ExcludeMissing - commitDuration: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + @JsonProperty("reseller_type") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), + resellerType: JsonField = JsonMissing.of(), @JsonProperty("applicable_product_ids") @ExcludeMissing applicableProductIds: JsonField> = JsonMissing.of(), @JsonProperty("applicable_product_tags") @ExcludeMissing applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("contract") + @JsonProperty("aws_account_number") @ExcludeMissing - contract: JsonField = JsonMissing.of(), - @JsonProperty("description") + awsAccountNumber: JsonField = JsonMissing.of(), + @JsonProperty("aws_offer_id") @ExcludeMissing - description: JsonField = JsonMissing.of(), + awsOfferId: JsonField = JsonMissing.of(), + @JsonProperty("aws_payer_reference_id") + @ExcludeMissing + awsPayerReferenceId: JsonField = JsonMissing.of(), @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") + @JsonProperty("fraction") @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("proration") + fraction: JsonField = JsonMissing.of(), + @JsonProperty("gcp_account_id") @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("recurrence_frequency") + gcpAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gcp_offer_id") @ExcludeMissing - recurrenceFrequency: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") + gcpOfferId: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_reseller_id") @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") + netsuiteResellerId: JsonField = JsonMissing.of(), + @JsonProperty("reseller_contract_value") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - @JsonProperty("subscription_config") + resellerContractValue: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - subscriptionConfig: JsonField = JsonMissing.of(), + startingAt: JsonField = JsonMissing.of(), ) : this( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAt, + resellerType, applicableProductIds, applicableProductTags, - contract, - description, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, mutableMapOf(), ) @@ -11403,63 +15623,9 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun id(): String = id.getRequired("id") - - /** - * The amount of commit to grant. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun accessAmount(): AccessAmount = accessAmount.getRequired("access_amount") - - /** - * The amount of time the created commits will be valid for - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun commitDuration(): CommitDuration = commitDuration.getRequired("commit_duration") - - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun priority(): Double = priority.getRequired("priority") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun product(): Product = product.getRequired("product") - - /** - * Whether the created commits will use the commit rate or list rate - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun rateType(): RateType = rateType.getRequired("rate_type") - - /** - * Determines the start time for the first commit - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") /** - * Will be passed down to the individual commits - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ @@ -11467,8 +15633,6 @@ private constructor( applicableProductIds.getOptional("applicable_product_ids") /** - * Will be passed down to the individual commits - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ @@ -11479,162 +15643,75 @@ private constructor( * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun contract(): Optional = contract.getOptional("contract") - - /** - * Will be passed down to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Determines when the contract will stop creating recurring commits. Optional - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - - /** - * Optional configuration for recurring credit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") - - /** - * Displayed on invoices. Will be passed through to the individual commits - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun awsAccountNumber(): Optional = + awsAccountNumber.getOptional("aws_account_number") /** - * Will be passed down to the individual commits - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun proration(): Optional = proration.getOptional("proration") + fun awsPayerReferenceId(): Optional = + awsPayerReferenceId.getOptional("aws_payer_reference_id") /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun recurrenceFrequency(): Optional = - recurrenceFrequency.getOptional("recurrence_frequency") + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be between - * 0 and 1. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + fun fraction(): Optional = fraction.getOptional("fraction") /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun specifiers(): Optional> = specifiers.getOptional("specifiers") + fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") /** - * Attach a subscription to the recurring commit/credit. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun subscriptionConfig(): Optional = - subscriptionConfig.getOptional("subscription_config") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount - - /** - * Returns the raw JSON value of [commitDuration]. - * - * Unlike [commitDuration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("commit_duration") - @ExcludeMissing - fun _commitDuration(): JsonField = commitDuration + * if the server responded with an unexpected value). + */ + fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + fun netsuiteResellerId(): Optional = + netsuiteResellerId.getOptional("netsuite_reseller_id") /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + fun resellerContractValue(): Optional = + resellerContractValue.getOptional("reseller_contract_value") /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + fun startingAt(): Optional = startingAt.getOptional("starting_at") /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [resellerType]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected + * Unlike [resellerType], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("starting_at") + @JsonProperty("reseller_type") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _resellerType(): JsonField = resellerType /** * Returns the raw JSON value of [applicableProductIds]. @@ -11657,113 +15734,102 @@ private constructor( fun _applicableProductTags(): JsonField> = applicableProductTags /** - * Returns the raw JSON value of [contract]. + * Returns the raw JSON value of [awsAccountNumber]. * - * Unlike [contract], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("contract") + @JsonProperty("aws_account_number") @ExcludeMissing - fun _contract(): JsonField = contract + fun _awsAccountNumber(): JsonField = awsAccountNumber /** - * Returns the raw JSON value of [description]. + * Returns the raw JSON value of [awsOfferId]. * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * Unlike [awsOfferId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("description") + @JsonProperty("aws_offer_id") @ExcludeMissing - fun _description(): JsonField = description + fun _awsOfferId(): JsonField = awsOfferId /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [awsPayerReferenceId]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("ending_before") + @JsonProperty("aws_payer_reference_id") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId /** - * Returns the raw JSON value of [hierarchyConfiguration]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("hierarchy_configuration") + @JsonProperty("ending_before") @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [fraction]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("fraction") @ExcludeMissing fun _fraction(): JsonField = fraction /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. + * Returns the raw JSON value of [gcpAccountId]. * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("netsuite_sales_order_id") + @JsonProperty("gcp_account_id") @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun _gcpAccountId(): JsonField = gcpAccountId /** - * Returns the raw JSON value of [proration]. + * Returns the raw JSON value of [gcpOfferId]. * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("proration") + @JsonProperty("gcp_offer_id") @ExcludeMissing - fun _proration(): JsonField = proration + fun _gcpOfferId(): JsonField = gcpOfferId /** - * Returns the raw JSON value of [recurrenceFrequency]. + * Returns the raw JSON value of [netsuiteResellerId]. * - * Unlike [recurrenceFrequency], this method doesn't throw if the JSON field has an + * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("recurrence_frequency") + @JsonProperty("netsuite_reseller_id") @ExcludeMissing - fun _recurrenceFrequency(): JsonField = recurrenceFrequency + fun _netsuiteResellerId(): JsonField = netsuiteResellerId /** - * Returns the raw JSON value of [rolloverFraction]. + * Returns the raw JSON value of [resellerContractValue]. * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * Unlike [resellerContractValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("rollover_fraction") + @JsonProperty("reseller_contract_value") @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + fun _resellerContractValue(): JsonField = resellerContractValue /** - * Returns the raw JSON value of [specifiers]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers - - /** - * Returns the raw JSON value of [subscriptionConfig]. - * - * Unlike [subscriptionConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_config") + @JsonProperty("starting_at") @ExcludeMissing - fun _subscriptionConfig(): JsonField = - subscriptionConfig + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11775,172 +15841,73 @@ private constructor( fun _additionalProperties(): Map = Collections.unmodifiableMap(additionalProperties) - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AddRecurringCredit]. - * - * The following fields are required: - * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddRecurringCredit]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var accessAmount: JsonField? = null - private var commitDuration: JsonField? = null - private var priority: JsonField? = null - private var product: JsonField? = null - private var rateType: JsonField? = null - private var startingAt: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var contract: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var proration: JsonField = JsonMissing.of() - private var recurrenceFrequency: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var subscriptionConfig: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addRecurringCredit: AddRecurringCredit) = apply { - id = addRecurringCredit.id - accessAmount = addRecurringCredit.accessAmount - commitDuration = addRecurringCredit.commitDuration - priority = addRecurringCredit.priority - product = addRecurringCredit.product - rateType = addRecurringCredit.rateType - startingAt = addRecurringCredit.startingAt - applicableProductIds = - addRecurringCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addRecurringCredit.applicableProductTags.map { it.toMutableList() } - contract = addRecurringCredit.contract - description = addRecurringCredit.description - endingBefore = addRecurringCredit.endingBefore - hierarchyConfiguration = addRecurringCredit.hierarchyConfiguration - name = addRecurringCredit.name - netsuiteSalesOrderId = addRecurringCredit.netsuiteSalesOrderId - proration = addRecurringCredit.proration - recurrenceFrequency = addRecurringCredit.recurrenceFrequency - rolloverFraction = addRecurringCredit.rolloverFraction - specifiers = addRecurringCredit.specifiers.map { it.toMutableList() } - subscriptionConfig = addRecurringCredit.subscriptionConfig - additionalProperties = addRecurringCredit.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** The amount of commit to grant. */ - fun accessAmount(accessAmount: AccessAmount) = - accessAmount(JsonField.of(accessAmount)) - - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } - - /** The amount of time the created commits will be valid for */ - fun commitDuration(commitDuration: CommitDuration) = - commitDuration(JsonField.of(commitDuration)) - - /** - * Sets [Builder.commitDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.commitDuration] with a well-typed - * [CommitDuration] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun commitDuration(commitDuration: JsonField) = apply { - this.commitDuration = commitDuration - } - - /** Will be passed down to the individual commits */ - fun priority(priority: Double) = priority(JsonField.of(priority)) - - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + fun toBuilder() = Builder().from(this) - fun product(product: Product) = product(JsonField.of(product)) + companion object { /** - * Sets [Builder.product] to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [AddResellerRoyalty]. * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * The following fields are required: + * ```java + * .resellerType() + * ``` */ - fun product(product: JsonField) = apply { this.product = product } + @JvmStatic fun builder() = Builder() + } - /** Whether the created commits will use the commit rate or list rate */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** A builder for [AddResellerRoyalty]. */ + class Builder internal constructor() { - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + private var resellerType: JsonField? = null + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var awsAccountNumber: JsonField = JsonMissing.of() + private var awsOfferId: JsonField = JsonMissing.of() + private var awsPayerReferenceId: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var fraction: JsonField = JsonMissing.of() + private var gcpAccountId: JsonField = JsonMissing.of() + private var gcpOfferId: JsonField = JsonMissing.of() + private var netsuiteResellerId: JsonField = JsonMissing.of() + private var resellerContractValue: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** Determines the start time for the first commit */ - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + @JvmSynthetic + internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { + resellerType = addResellerRoyalty.resellerType + applicableProductIds = + addResellerRoyalty.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + addResellerRoyalty.applicableProductTags.map { it.toMutableList() } + awsAccountNumber = addResellerRoyalty.awsAccountNumber + awsOfferId = addResellerRoyalty.awsOfferId + awsPayerReferenceId = addResellerRoyalty.awsPayerReferenceId + endingBefore = addResellerRoyalty.endingBefore + fraction = addResellerRoyalty.fraction + gcpAccountId = addResellerRoyalty.gcpAccountId + gcpOfferId = addResellerRoyalty.gcpOfferId + netsuiteResellerId = addResellerRoyalty.netsuiteResellerId + resellerContractValue = addResellerRoyalty.resellerContractValue + startingAt = addResellerRoyalty.startingAt + additionalProperties = addResellerRoyalty.additionalProperties.toMutableMap() + } + + fun resellerType(resellerType: ResellerType) = + resellerType(JsonField.of(resellerType)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.resellerType] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * You should usually call [Builder.resellerType] with a well-typed [ResellerType] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun resellerType(resellerType: JsonField) = apply { + this.resellerType = resellerType } - /** Will be passed down to the individual commits */ fun applicableProductIds(applicableProductIds: List) = applicableProductIds(JsonField.of(applicableProductIds)) @@ -11967,7 +15934,6 @@ private constructor( } } - /** Will be passed down to the individual commits */ fun applicableProductTags(applicableProductTags: List) = applicableProductTags(JsonField.of(applicableProductTags)) @@ -11994,191 +15960,142 @@ private constructor( } } - fun contract(contract: Contract) = contract(JsonField.of(contract)) + fun awsAccountNumber(awsAccountNumber: String) = + awsAccountNumber(JsonField.of(awsAccountNumber)) /** - * Sets [Builder.contract] to an arbitrary JSON value. + * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. * - * You should usually call [Builder.contract] with a well-typed [Contract] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.awsAccountNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun contract(contract: JsonField) = apply { this.contract = contract } + fun awsAccountNumber(awsAccountNumber: JsonField) = apply { + this.awsAccountNumber = awsAccountNumber + } - /** Will be passed down to the individual commits */ - fun description(description: String) = description(JsonField.of(description)) + fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) /** - * Sets [Builder.description] to an arbitrary JSON value. + * Sets [Builder.awsOfferId] to an arbitrary JSON value. * - * You should usually call [Builder.description] with a well-typed [String] value + * You should usually call [Builder.awsOfferId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun description(description: JsonField) = apply { - this.description = description + fun awsOfferId(awsOfferId: JsonField) = apply { + this.awsOfferId = awsOfferId } - /** Determines when the contract will stop creating recurring commits. Optional */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun awsPayerReferenceId(awsPayerReferenceId: String) = + awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * You should usually call [Builder.awsPayerReferenceId] with a well-typed [String] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { + this.awsPayerReferenceId = awsPayerReferenceId } - /** Optional configuration for recurring credit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - - /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - - /** Displayed on invoices. Will be passed through to the individual commits */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun endingBefore(endingBefore: OffsetDateTime?) = + endingBefore(JsonField.ofNullable(endingBefore)) - /** Will be passed down to the individual commits */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = + endingBefore(endingBefore.getOrNull()) /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - /** - * Determines whether the first and last commit will be prorated. If not provided, - * the default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - fun proration(proration: Proration) = proration(JsonField.of(proration)) + fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) /** - * Sets [Builder.proration] to an arbitrary JSON value. + * Sets [Builder.fraction] to an arbitrary JSON value. * - * You should usually call [Builder.proration] with a well-typed [Proration] value + * You should usually call [Builder.fraction] with a well-typed [Double] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun proration(proration: JsonField) = apply { - this.proration = proration - } + fun fraction(fraction: JsonField) = apply { this.fraction = fraction } - /** - * The frequency at which the recurring commits will be created. If not provided: - - * The commits will be created on the usage invoice frequency. If provided: - The - * period defined in the duration will correspond to this frequency. - Commits will - * be created aligned with the recurring commit's starting_at rather than the usage - * invoice dates. - */ - fun recurrenceFrequency(recurrenceFrequency: RecurrenceFrequency) = - recurrenceFrequency(JsonField.of(recurrenceFrequency)) + fun gcpAccountId(gcpAccountId: String) = gcpAccountId(JsonField.of(gcpAccountId)) /** - * Sets [Builder.recurrenceFrequency] to an arbitrary JSON value. + * Sets [Builder.gcpAccountId] to an arbitrary JSON value. * - * You should usually call [Builder.recurrenceFrequency] with a well-typed - * [RecurrenceFrequency] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.gcpAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun recurrenceFrequency(recurrenceFrequency: JsonField) = - apply { - this.recurrenceFrequency = recurrenceFrequency - } + fun gcpAccountId(gcpAccountId: JsonField) = apply { + this.gcpAccountId = gcpAccountId + } - /** - * Will be passed down to the individual commits. This controls how much of an - * individual unexpired commit will roll over upon contract transition. Must be - * between 0 and 1. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(JsonField.of(rolloverFraction)) + fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * Sets [Builder.gcpOfferId] to an arbitrary JSON value. * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.gcpOfferId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction + fun gcpOfferId(gcpOfferId: JsonField) = apply { + this.gcpOfferId = gcpOfferId } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. - */ - fun specifiers(specifiers: List) = - specifiers(JsonField.of(specifiers)) + fun netsuiteResellerId(netsuiteResellerId: String) = + netsuiteResellerId(JsonField.of(netsuiteResellerId)) /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.netsuiteResellerId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } + fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { + this.netsuiteResellerId = netsuiteResellerId } + fun resellerContractValue(resellerContractValue: Double) = + resellerContractValue(JsonField.of(resellerContractValue)) + /** - * Adds a single [CommitSpecifier] to [specifiers]. + * Sets [Builder.resellerContractValue] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifier) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } + * You should usually call [Builder.resellerContractValue] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun resellerContractValue(resellerContractValue: JsonField) = apply { + this.resellerContractValue = resellerContractValue } - /** Attach a subscription to the recurring commit/credit. */ - fun subscriptionConfig(subscriptionConfig: RecurringCommitSubscriptionConfig) = - subscriptionConfig(JsonField.of(subscriptionConfig)) + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.subscriptionConfig] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.subscriptionConfig] with a well-typed - * [RecurringCommitSubscriptionConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun subscriptionConfig( - subscriptionConfig: JsonField - ) = apply { this.subscriptionConfig = subscriptionConfig } + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -12203,45 +16120,32 @@ private constructor( } /** - * Returns an immutable instance of [AddRecurringCredit]. + * Returns an immutable instance of [AddResellerRoyalty]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() - * .accessAmount() - * .commitDuration() - * .priority() - * .product() - * .rateType() - * .startingAt() + * .resellerType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddRecurringCredit = - AddRecurringCredit( - checkRequired("id", id), - checkRequired("accessAmount", accessAmount), - checkRequired("commitDuration", commitDuration), - checkRequired("priority", priority), - checkRequired("product", product), - checkRequired("rateType", rateType), - checkRequired("startingAt", startingAt), + fun build(): AddResellerRoyalty = + AddResellerRoyalty( + checkRequired("resellerType", resellerType), (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - contract, - description, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - subscriptionConfig, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, additionalProperties.toMutableMap(), ) } @@ -12258,681 +16162,567 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): AddRecurringCredit = apply { + fun validate(): AddResellerRoyalty = apply { if (validated) { return@apply } - id() - accessAmount().validate() - commitDuration().validate() - priority() - product().validate() - rateType().validate() - startingAt() + resellerType().validate() applicableProductIds() applicableProductTags() - contract().ifPresent { it.validate() } - description() + awsAccountNumber() + awsOfferId() + awsPayerReferenceId() endingBefore() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - proration().ifPresent { it.validate() } - recurrenceFrequency().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - subscriptionConfig().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (commitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (contract.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (recurrenceFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (subscriptionConfig.asKnown().getOrNull()?.validity() ?: 0) - - /** The amount of commit to grant. */ - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val creditTypeId: JsonField, - private val unitPrice: JsonField, - private val quantity: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - ) : this(creditTypeId, unitPrice, quantity, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun creditTypeId(): String = creditTypeId.getRequired("credit_type_id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun unitPrice(): Double = unitPrice.getRequired("unit_price") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId - - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @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 [AccessAmount]. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { - - private var creditTypeId: JsonField? = null - private var unitPrice: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - creditTypeId = accessAmount.creditTypeId - unitPrice = accessAmount.unitPrice - quantity = accessAmount.quantity - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } - - fun creditTypeId(creditTypeId: String) = - creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + fraction() + gcpAccountId() + gcpOfferId() + netsuiteResellerId() + resellerContractValue() + startingAt() + validated = true + } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (resellerType.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + + (if (awsOfferId.asKnown().isPresent) 1 else 0) + + (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (fraction.asKnown().isPresent) 1 else 0) + + (if (gcpAccountId.asKnown().isPresent) 1 else 0) + + (if (gcpOfferId.asKnown().isPresent) 1 else 0) + + (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + + (if (resellerContractValue.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + class ResellerType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val AWS = of("AWS") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val GCP = of("GCP") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditTypeId() - * .unitPrice() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AccessAmount = - AccessAmount( - checkRequired("creditTypeId", creditTypeId), - checkRequired("unitPrice", unitPrice), - quantity, - additionalProperties.toMutableMap(), - ) + @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) } - private var validated: Boolean = false + /** An enum containing [ResellerType]'s known values. */ + enum class Known { + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, + } /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] + * member. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * An instance of [ResellerType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply - } - - creditTypeId() - unitPrice() - quantity() - validated = true + enum class Value { + AWS, + AWS_PRO_SERVICE, + GCP, + GCP_PRO_SERVICE, + /** + * An enum member indicating that [ResellerType] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * Used for best match union deserialization. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - @JvmSynthetic - internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun value(): Value = + when (this) { + AWS -> Value.AWS + AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE + GCP -> Value.GCP + GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE + else -> Value._UNKNOWN } - return other is AccessAmount && - creditTypeId == other.creditTypeId && - unitPrice == other.unitPrice && - quantity == other.quantity && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(creditTypeId, unitPrice, quantity, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccessAmount{creditTypeId=$creditTypeId, unitPrice=$unitPrice, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - /** The amount of time the created commits will be valid for */ - class CommitDuration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val value: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), - ) : this(value, unit, mutableMapOf()) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - fun value(): Double = value.getRequired("value") + fun known(): Known = + when (this) { + AWS -> Known.AWS + AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE + GCP -> Known.GCP + GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE + else -> throw MetronomeInvalidDataException("Unknown ResellerType: $value") + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun unit(): Optional = unit.getOptional("unit") + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [value]. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + fun validate(): ResellerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [unit]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is ResellerType && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - /** - * Returns a mutable builder for constructing an instance of [CommitDuration]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [CommitDuration]. */ - class Builder internal constructor() { + return other is AddResellerRoyalty && + resellerType == other.resellerType && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + awsAccountNumber == other.awsAccountNumber && + awsOfferId == other.awsOfferId && + awsPayerReferenceId == other.awsPayerReferenceId && + endingBefore == other.endingBefore && + fraction == other.fraction && + gcpAccountId == other.gcpAccountId && + gcpOfferId == other.gcpOfferId && + netsuiteResellerId == other.netsuiteResellerId && + resellerContractValue == other.resellerContractValue && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - private var value: JsonField? = null - private var unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash( + resellerType, + applicableProductIds, + applicableProductTags, + awsAccountNumber, + awsOfferId, + awsPayerReferenceId, + endingBefore, + fraction, + gcpAccountId, + gcpOfferId, + netsuiteResellerId, + resellerContractValue, + startingAt, + additionalProperties, + ) + } - @JvmSynthetic - internal fun from(commitDuration: CommitDuration) = apply { - value = commitDuration.value - unit = commitDuration.unit - additionalProperties = commitDuration.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun value(value: Double) = value(JsonField.of(value)) + override fun toString() = + "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, endingBefore=$endingBefore, fraction=$fraction, gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + class AddScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val product: JsonField, + private val schedule: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun unit(unit: Unit) = unit(JsonField.of(unit)) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + @JsonProperty("schedule") + @ExcludeMissing + schedule: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + ) : this(id, product, schedule, name, netsuiteSalesOrderId, mutableMapOf()) - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Unit] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun product(): Product = product.getRequired("product") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun schedule(): SchedulePointInTime = schedule.getRequired("schedule") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * displayed on invoices + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * This field's availability is dependent on your client's configuration. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns an immutable instance of [CommitDuration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CommitDuration = - CommitDuration( - checkRequired("value", value), - unit, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + + /** + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): CommitDuration = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - value() - unit().ifPresent { it.validate() } - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of [AddScheduledCharge]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .id() + * .product() + * .schedule() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (if (value.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) - - class Unit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERIODS = of("PERIODS") - - @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) - } + @JvmStatic fun builder() = Builder() + } - /** An enum containing [Unit]'s known values. */ - enum class Known { - PERIODS - } + /** A builder for [AddScheduledCharge]. */ + class Builder internal constructor() { - /** - * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Unit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERIODS, - /** - * An enum member indicating that [Unit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var id: JsonField? = null + private var product: JsonField? = null + private var schedule: JsonField? = null + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERIODS -> Value.PERIODS - else -> Value._UNKNOWN - } + @JvmSynthetic + internal fun from(addScheduledCharge: AddScheduledCharge) = apply { + id = addScheduledCharge.id + product = addScheduledCharge.product + schedule = addScheduledCharge.schedule + name = addScheduledCharge.name + netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId + additionalProperties = addScheduledCharge.additionalProperties.toMutableMap() + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - PERIODS -> Known.PERIODS - else -> throw MetronomeInvalidDataException("Unknown Unit: $value") - } + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - private var validated: Boolean = false + fun product(product: Product) = product(JsonField.of(product)) - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Unit = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.product] to an arbitrary JSON value. + * + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun product(product: JsonField) = apply { this.product = product } - known() - validated = true - } + fun schedule(schedule: SchedulePointInTime) = schedule(JsonField.of(schedule)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed + * [SchedulePointInTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun schedule(schedule: JsonField) = apply { + this.schedule = schedule + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** displayed on invoices */ + fun name(name: String) = name(JsonField.of(name)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - return other is Unit && value == other.value - } + /** This field's availability is dependent on your client's configuration. */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - return other is CommitDuration && - value == other.value && - unit == other.unit && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(value, unit, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode + /** + * Returns an immutable instance of [AddScheduledCharge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .product() + * .schedule() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduledCharge = + AddScheduledCharge( + checkRequired("id", id), + checkRequired("product", product), + checkRequired("schedule", schedule), + name, + netsuiteSalesOrderId, + additionalProperties.toMutableMap(), + ) + } - override fun toString() = - "CommitDuration{value=$value, unit=$unit, additionalProperties=$additionalProperties}" + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AddScheduledCharge = apply { + if (validated) { + return@apply + } + + id() + product().validate() + schedule().validate() + name() + netsuiteSalesOrderId() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + class Product @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -13063,175 +16853,23 @@ private constructor( /** * Returns an immutable instance of [Product]. * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - /** Whether the created commits will use the commit rate or list rate */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } - - /** An enum containing [RateType]'s known values. */ - enum class Known { - COMMIT_RATE, - LIST_RATE, - } - - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT_RATE, - LIST_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT_RATE -> Value.COMMIT_RATE - LIST_RATE -> Value.LIST_RATE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - COMMIT_RATE -> Known.COMMIT_RATE - LIST_RATE -> Known.LIST_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } private var validated: Boolean = false @@ -13245,12 +16883,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): RateType = apply { + fun validate(): Product = apply { if (validated) { return@apply } - known() + id() + name() validated = true } @@ -13268,1795 +16907,1967 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddScheduledCharge && + id == other.id && + product == other.product && + schedule == other.schedule && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + product, + schedule, + name, + netsuiteSalesOrderId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddScheduledCharge{id=$id, product=$product, schedule=$schedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" + } + + class AddSubscription + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingPeriods: JsonField, + private val collectionSchedule: JsonField, + private val proration: JsonField, + private val quantityManagementMode: JsonField, + private val quantitySchedule: JsonField>, + private val startingAt: JsonField, + private val subscriptionRate: JsonField, + private val id: JsonField, + private val billingCycleConfig: JsonField, + private val customFields: JsonField, + private val description: JsonField, + private val endingBefore: JsonField, + private val fiatCreditTypeId: JsonField, + private val name: JsonField, + private val seatConfig: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("billing_periods") + @ExcludeMissing + billingPeriods: JsonField = JsonMissing.of(), + @JsonProperty("collection_schedule") + @ExcludeMissing + collectionSchedule: JsonField = JsonMissing.of(), + @JsonProperty("proration") + @ExcludeMissing + proration: JsonField = JsonMissing.of(), + @JsonProperty("quantity_management_mode") + @ExcludeMissing + quantityManagementMode: JsonField = JsonMissing.of(), + @JsonProperty("quantity_schedule") + @ExcludeMissing + quantitySchedule: JsonField> = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("subscription_rate") + @ExcludeMissing + subscriptionRate: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_config") + @ExcludeMissing + billingCycleConfig: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fiatCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("seat_config") + @ExcludeMissing + seatConfig: JsonField = JsonMissing.of(), + ) : this( + billingPeriods, + collectionSchedule, + proration, + quantityManagementMode, + quantitySchedule, + startingAt, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + mutableMapOf(), + ) + + /** + * Previous, current, and next billing periods for the subscription. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun billingPeriods(): BillingPeriods = billingPeriods.getRequired("billing_periods") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun collectionSchedule(): CollectionSchedule = + collectionSchedule.getRequired("collection_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun proration(): Proration = proration.getRequired("proration") + + /** + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per + * seat. `seat_config` must be provided with this option. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantityManagementMode(): QuantityManagementMode = + quantityManagementMode.getRequired("quantity_management_mode") + + /** + * List of quantity schedule items for the subscription. Only includes the current + * quantity and future quantity changes. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantitySchedule(): List = + quantitySchedule.getRequired("quantity_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionRate(): SubscriptionRate = + subscriptionRate.getRequired("subscription_rate") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun billingCycleConfig(): Optional = + billingCycleConfig.getOptional("billing_cycle_config") + + /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customFields(): Optional = customFields.getOptional("custom_fields") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fiatCreditTypeId(): Optional = + fiatCreditTypeId.getOptional("fiat_credit_type_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - return other is RateType && value == other.value - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun seatConfig(): Optional = seatConfig.getOptional("seat_config") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [billingPeriods]. + * + * Unlike [billingPeriods], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_periods") + @ExcludeMissing + fun _billingPeriods(): JsonField = billingPeriods - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [collectionSchedule]. + * + * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_schedule") + @ExcludeMissing + fun _collectionSchedule(): JsonField = collectionSchedule - class Contract - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [proration]. + * + * Unlike [proration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("proration") + @ExcludeMissing + fun _proration(): JsonField = proration - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Returns the raw JSON value of [quantityManagementMode]. + * + * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_management_mode") + @ExcludeMissing + fun _quantityManagementMode(): JsonField = + quantityManagementMode - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns the raw JSON value of [quantitySchedule]. + * + * Unlike [quantitySchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity_schedule") + @ExcludeMissing + fun _quantitySchedule(): JsonField> = quantitySchedule - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [subscriptionRate]. + * + * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_rate") + @ExcludeMissing + fun _subscriptionRate(): JsonField = subscriptionRate - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [billingCycleConfig]. + * + * Unlike [billingCycleConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_config") + @ExcludeMissing + fun _billingCycleConfig(): JsonField = billingCycleConfig - companion object { + /** + * Returns the raw JSON value of [customFields]. + * + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - /** - * Returns a mutable builder for constructing an instance of [Contract]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** A builder for [Contract]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [fiatCreditTypeId]. + * + * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fiat_credit_type_id") + @ExcludeMissing + fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId - @JvmSynthetic - internal fun from(contract: Contract) = apply { - id = contract.id - additionalProperties = contract.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun id(id: String) = id(JsonField.of(id)) + /** + * Returns the raw JSON value of [seatConfig]. + * + * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("seat_config") + @ExcludeMissing + fun _seatConfig(): JsonField = seatConfig - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of [AddSubscription]. + * + * The following fields are required: + * ```java + * .billingPeriods() + * .collectionSchedule() + * .proration() + * .quantityManagementMode() + * .quantitySchedule() + * .startingAt() + * .subscriptionRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [AddSubscription]. */ + class Builder internal constructor() { + + private var billingPeriods: JsonField? = null + private var collectionSchedule: JsonField? = null + private var proration: JsonField? = null + private var quantityManagementMode: JsonField? = null + private var quantitySchedule: JsonField>? = null + private var startingAt: JsonField? = null + private var subscriptionRate: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var billingCycleConfig: JsonField = JsonMissing.of() + private var customFields: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var fiatCreditTypeId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var seatConfig: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an immutable instance of [Contract]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Contract = - Contract(checkRequired("id", id), additionalProperties.toMutableMap()) + @JvmSynthetic + internal fun from(addSubscription: AddSubscription) = apply { + billingPeriods = addSubscription.billingPeriods + collectionSchedule = addSubscription.collectionSchedule + proration = addSubscription.proration + quantityManagementMode = addSubscription.quantityManagementMode + quantitySchedule = addSubscription.quantitySchedule.map { it.toMutableList() } + startingAt = addSubscription.startingAt + subscriptionRate = addSubscription.subscriptionRate + id = addSubscription.id + billingCycleConfig = addSubscription.billingCycleConfig + customFields = addSubscription.customFields + description = addSubscription.description + endingBefore = addSubscription.endingBefore + fiatCreditTypeId = addSubscription.fiatCreditTypeId + name = addSubscription.name + seatConfig = addSubscription.seatConfig + additionalProperties = addSubscription.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** Previous, current, and next billing periods for the subscription. */ + fun billingPeriods(billingPeriods: BillingPeriods) = + billingPeriods(JsonField.of(billingPeriods)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.billingPeriods] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.billingPeriods] with a well-typed + * [BillingPeriods] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun validate(): Contract = apply { - if (validated) { - return@apply - } - - id() - validated = true + fun billingPeriods(billingPeriods: JsonField) = apply { + this.billingPeriods = billingPeriods } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun collectionSchedule(collectionSchedule: CollectionSchedule) = + collectionSchedule(JsonField.of(collectionSchedule)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.collectionSchedule] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.collectionSchedule] with a well-typed + * [CollectionSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + fun collectionSchedule(collectionSchedule: JsonField) = apply { + this.collectionSchedule = collectionSchedule + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun proration(proration: Proration) = proration(JsonField.of(proration)) - return other is Contract && - id == other.id && - additionalProperties == other.additionalProperties + /** + * Sets [Builder.proration] to an arbitrary JSON value. + * + * You should usually call [Builder.proration] with a well-typed [Proration] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun proration(proration: JsonField) = apply { + this.proration = proration } - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Determines how the subscription's quantity is controlled. Defaults to + * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly + * on the subscription. `initial_quantity` must be provided with this option. + * Compatible with recurring commits/credits that use POOLED allocation. + * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add + * user_123) to increment and decrement a subscription quantity, rather than + * directly providing the quantity. You must use a **SEAT_BASED** subscription to + * use a linked recurring credit with an allocation per seat. `seat_config` must be + * provided with this option. + */ + fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = + quantityManagementMode(JsonField.of(quantityManagementMode)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. + * + * You should usually call [Builder.quantityManagementMode] with a well-typed + * [QuantityManagementMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantityManagementMode( + quantityManagementMode: JsonField + ) = apply { this.quantityManagementMode = quantityManagementMode } - override fun toString() = - "Contract{id=$id, additionalProperties=$additionalProperties}" - } + /** + * List of quantity schedule items for the subscription. Only includes the current + * quantity and future quantity changes. + */ + fun quantitySchedule(quantitySchedule: List) = + quantitySchedule(JsonField.of(quantitySchedule)) - /** - * Determines whether the first and last commit will be prorated. If not provided, the - * default is FIRST_AND_LAST (i.e. prorate both the first and last commits). - */ - class Proration @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Sets [Builder.quantitySchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.quantitySchedule] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun quantitySchedule(quantitySchedule: JsonField>) = apply { + this.quantitySchedule = quantitySchedule.map { it.toMutableList() } + } /** - * Returns this class instance's raw value. + * Adds a single [QuantitySchedule] to [Builder.quantitySchedule]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * @throws IllegalStateException if the field was previously set to a non-list. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun addQuantitySchedule(quantitySchedule: QuantitySchedule) = apply { + this.quantitySchedule = + (this.quantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("quantitySchedule", it).add(quantitySchedule) + } + } - companion object { + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) - @JvmField val NONE = of("NONE") + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - @JvmField val FIRST = of("FIRST") + fun subscriptionRate(subscriptionRate: SubscriptionRate) = + subscriptionRate(JsonField.of(subscriptionRate)) - @JvmField val LAST = of("LAST") + /** + * Sets [Builder.subscriptionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionRate] with a well-typed + * [SubscriptionRate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscriptionRate(subscriptionRate: JsonField) = apply { + this.subscriptionRate = subscriptionRate + } - @JvmField val FIRST_AND_LAST = of("FIRST_AND_LAST") + fun id(id: String) = id(JsonField.of(id)) - @JvmStatic fun of(value: String) = Proration(JsonField.of(value)) - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** An enum containing [Proration]'s known values. */ - enum class Known { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - } + fun billingCycleConfig(billingCycleConfig: BillingCycleConfig) = + billingCycleConfig(JsonField.of(billingCycleConfig)) /** - * An enum containing [Proration]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.billingCycleConfig] to an arbitrary JSON value. * - * An instance of [Proration] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * You should usually call [Builder.billingCycleConfig] with a well-typed + * [BillingCycleConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - enum class Value { - NONE, - FIRST, - LAST, - FIRST_AND_LAST, - /** - * An enum member indicating that [Proration] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billingCycleConfig(billingCycleConfig: JsonField) = apply { + this.billingCycleConfig = billingCycleConfig } + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = + customFields(JsonField.of(customFields)) + /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.customFields] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * You should usually call [Builder.customFields] with a well-typed [CustomFields] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - FIRST -> Value.FIRST - LAST -> Value.LAST - FIRST_AND_LAST -> Value.FIRST_AND_LAST - else -> Value._UNKNOWN - } + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } + + fun description(description: String) = description(JsonField.of(description)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.description] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - FIRST -> Known.FIRST - LAST -> Known.LAST - FIRST_AND_LAST -> Known.FIRST_AND_LAST - else -> throw MetronomeInvalidDataException("Unknown Proration: $value") - } + fun description(description: JsonField) = apply { + this.description = description + } + + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - private var validated: Boolean = false + fun fiatCreditTypeId(fiatCreditTypeId: String) = + fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun validate(): Proration = apply { - if (validated) { - return@apply - } - - known() - validated = true + fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { + this.fiatCreditTypeId = fiatCreditTypeId } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun name(name: String) = name(JsonField.of(name)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.name] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun name(name: JsonField) = apply { this.name = name } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) - return other is Proration && value == other.value + /** + * Sets [Builder.seatConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun seatConfig(seatConfig: JsonField) = apply { + this.seatConfig = seatConfig } - override fun hashCode() = value.hashCode() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun toString() = value.toString() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The frequency at which the recurring commits will be created. If not provided: - The - * commits will be created on the usage invoice frequency. If provided: - The period - * defined in the duration will correspond to this frequency. - Commits will be created - * aligned with the recurring commit's starting_at rather than the usage invoice dates. - */ - class RecurrenceFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns this class instance's raw value. + * Returns an immutable instance of [AddSubscription]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingPeriods() + * .collectionSchedule() + * .proration() + * .quantityManagementMode() + * .quantitySchedule() + * .startingAt() + * .subscriptionRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MONTHLY = of("MONTHLY") + fun build(): AddSubscription = + AddSubscription( + checkRequired("billingPeriods", billingPeriods), + checkRequired("collectionSchedule", collectionSchedule), + checkRequired("proration", proration), + checkRequired("quantityManagementMode", quantityManagementMode), + checkRequired("quantitySchedule", quantitySchedule).map { + it.toImmutable() + }, + checkRequired("startingAt", startingAt), + checkRequired("subscriptionRate", subscriptionRate), + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + additionalProperties.toMutableMap(), + ) + } - @JvmField val QUARTERLY = of("QUARTERLY") + private var validated: Boolean = false - @JvmField val ANNUAL = of("ANNUAL") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AddSubscription = apply { + if (validated) { + return@apply + } - @JvmField val WEEKLY = of("WEEKLY") + billingPeriods().validate() + collectionSchedule().validate() + proration().validate() + quantityManagementMode().validate() + quantitySchedule().forEach { it.validate() } + startingAt() + subscriptionRate().validate() + id() + billingCycleConfig().ifPresent { it.validate() } + customFields().ifPresent { it.validate() } + description() + endingBefore() + fiatCreditTypeId() + name() + seatConfig().ifPresent { it.validate() } + validated = true + } - @JvmStatic fun of(value: String) = RecurrenceFrequency(JsonField.of(value)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - /** An enum containing [RecurrenceFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (billingPeriods.asKnown().getOrNull()?.validity() ?: 0) + + (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (proration.asKnown().getOrNull()?.validity() ?: 0) + + (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + + (quantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (billingCycleConfig.asKnown().getOrNull()?.validity() ?: 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + + /** Previous, current, and next billing periods for the subscription. */ + class BillingPeriods + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val current: JsonField, + private val next: JsonField, + private val previous: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("current") + @ExcludeMissing + current: JsonField = JsonMissing.of(), + @JsonProperty("next") @ExcludeMissing next: JsonField = JsonMissing.of(), + @JsonProperty("previous") + @ExcludeMissing + previous: JsonField = JsonMissing.of(), + ) : this(current, next, previous, mutableMapOf()) /** - * An enum containing [RecurrenceFrequency]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [RecurrenceFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [RecurrenceFrequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun current(): Optional = current.getOptional("current") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + fun next(): Optional = next.getOptional("next") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown RecurrenceFrequency: $value" - ) - } + fun previous(): Optional = previous.getOptional("previous") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns the raw JSON value of [current]. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * Unlike [current], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + @JsonProperty("current") + @ExcludeMissing + fun _current(): JsonField = current /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns the raw JSON value of [next]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * Unlike [next], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun validate(): RecurrenceFrequency = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonProperty("next") @ExcludeMissing fun _next(): JsonField = next /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [previous]. * - * Used for best match union deserialization. + * Unlike [previous], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RecurrenceFrequency && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddRecurringCredit && - id == other.id && - accessAmount == other.accessAmount && - commitDuration == other.commitDuration && - priority == other.priority && - product == other.product && - rateType == other.rateType && - startingAt == other.startingAt && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - contract == other.contract && - description == other.description && - endingBefore == other.endingBefore && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - proration == other.proration && - recurrenceFrequency == other.recurrenceFrequency && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - subscriptionConfig == other.subscriptionConfig && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - commitDuration, - priority, - product, - rateType, - startingAt, - applicableProductIds, - applicableProductTags, - contract, - description, - endingBefore, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - proration, - recurrenceFrequency, - rolloverFraction, - specifiers, - subscriptionConfig, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddRecurringCredit{id=$id, accessAmount=$accessAmount, commitDuration=$commitDuration, priority=$priority, product=$product, rateType=$rateType, startingAt=$startingAt, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, contract=$contract, description=$description, endingBefore=$endingBefore, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, proration=$proration, recurrenceFrequency=$recurrenceFrequency, rolloverFraction=$rolloverFraction, specifiers=$specifiers, subscriptionConfig=$subscriptionConfig, additionalProperties=$additionalProperties}" - } - - class AddResellerRoyalty - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val resellerType: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val awsAccountNumber: JsonField, - private val awsOfferId: JsonField, - private val awsPayerReferenceId: JsonField, - private val endingBefore: JsonField, - private val fraction: JsonField, - private val gcpAccountId: JsonField, - private val gcpOfferId: JsonField, - private val netsuiteResellerId: JsonField, - private val resellerContractValue: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("reseller_type") - @ExcludeMissing - resellerType: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("aws_account_number") - @ExcludeMissing - awsAccountNumber: JsonField = JsonMissing.of(), - @JsonProperty("aws_offer_id") - @ExcludeMissing - awsOfferId: JsonField = JsonMissing.of(), - @JsonProperty("aws_payer_reference_id") - @ExcludeMissing - awsPayerReferenceId: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("fraction") - @ExcludeMissing - fraction: JsonField = JsonMissing.of(), - @JsonProperty("gcp_account_id") - @ExcludeMissing - gcpAccountId: JsonField = JsonMissing.of(), - @JsonProperty("gcp_offer_id") - @ExcludeMissing - gcpOfferId: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_reseller_id") - @ExcludeMissing - netsuiteResellerId: JsonField = JsonMissing.of(), - @JsonProperty("reseller_contract_value") - @ExcludeMissing - resellerContractValue: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + @JsonProperty("previous") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this( - resellerType, - applicableProductIds, - applicableProductTags, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - mutableMapOf(), - ) + fun _previous(): JsonField = previous - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun resellerType(): ResellerType = resellerType.getRequired("reseller_type") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + fun toBuilder() = Builder().from(this) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsAccountNumber(): Optional = - awsAccountNumber.getOptional("aws_account_number") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsOfferId(): Optional = awsOfferId.getOptional("aws_offer_id") + /** + * Returns a mutable builder for constructing an instance of [BillingPeriods]. + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun awsPayerReferenceId(): Optional = - awsPayerReferenceId.getOptional("aws_payer_reference_id") + /** A builder for [BillingPeriods]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + private var current: JsonField = JsonMissing.of() + private var next: JsonField = JsonMissing.of() + private var previous: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun fraction(): Optional = fraction.getOptional("fraction") + @JvmSynthetic + internal fun from(billingPeriods: BillingPeriods) = apply { + current = billingPeriods.current + next = billingPeriods.next + previous = billingPeriods.previous + additionalProperties = billingPeriods.additionalProperties.toMutableMap() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gcpAccountId(): Optional = gcpAccountId.getOptional("gcp_account_id") + fun current(current: Current) = current(JsonField.of(current)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gcpOfferId(): Optional = gcpOfferId.getOptional("gcp_offer_id") + /** + * Sets [Builder.current] to an arbitrary JSON value. + * + * You should usually call [Builder.current] with a well-typed [Current] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun current(current: JsonField) = apply { this.current = current } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun netsuiteResellerId(): Optional = - netsuiteResellerId.getOptional("netsuite_reseller_id") + fun next(next: Next) = next(JsonField.of(next)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun resellerContractValue(): Optional = - resellerContractValue.getOptional("reseller_contract_value") + /** + * Sets [Builder.next] to an arbitrary JSON value. + * + * You should usually call [Builder.next] with a well-typed [Next] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun next(next: JsonField) = apply { this.next = next } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun startingAt(): Optional = startingAt.getOptional("starting_at") + fun previous(previous: Previous) = previous(JsonField.of(previous)) - /** - * Returns the raw JSON value of [resellerType]. - * - * Unlike [resellerType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reseller_type") - @ExcludeMissing - fun _resellerType(): JsonField = resellerType + /** + * Sets [Builder.previous] to an arbitrary JSON value. + * + * You should usually call [Builder.previous] with a well-typed [Previous] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun previous(previous: JsonField) = apply { this.previous = previous } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [awsAccountNumber]. - * - * Unlike [awsAccountNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_account_number") - @ExcludeMissing - fun _awsAccountNumber(): JsonField = awsAccountNumber + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingPeriods]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BillingPeriods = + BillingPeriods(current, next, previous, 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BillingPeriods = apply { + if (validated) { + return@apply + } + + current().ifPresent { it.validate() } + next().ifPresent { it.validate() } + previous().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (current.asKnown().getOrNull()?.validity() ?: 0) + + (next.asKnown().getOrNull()?.validity() ?: 0) + + (previous.asKnown().getOrNull()?.validity() ?: 0) + + class Current + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [awsOfferId]. - * - * Unlike [awsOfferId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("aws_offer_id") - @ExcludeMissing - fun _awsOfferId(): JsonField = awsOfferId + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - /** - * Returns the raw JSON value of [awsPayerReferenceId]. - * - * Unlike [awsPayerReferenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("aws_payer_reference_id") - @ExcludeMissing - fun _awsPayerReferenceId(): JsonField = awsPayerReferenceId + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * Returns the raw JSON value of [fraction]. - * - * Unlike [fraction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fraction") @ExcludeMissing fun _fraction(): JsonField = fraction + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * Returns the raw JSON value of [gcpAccountId]. - * - * Unlike [gcpAccountId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gcp_account_id") - @ExcludeMissing - fun _gcpAccountId(): JsonField = gcpAccountId + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Returns the raw JSON value of [gcpOfferId]. - * - * Unlike [gcpOfferId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gcp_offer_id") - @ExcludeMissing - fun _gcpOfferId(): JsonField = gcpOfferId + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [netsuiteResellerId]. - * - * Unlike [netsuiteResellerId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_reseller_id") - @ExcludeMissing - fun _netsuiteResellerId(): JsonField = netsuiteResellerId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [resellerContractValue]. - * - * Unlike [resellerContractValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reseller_contract_value") - @ExcludeMissing - fun _resellerContractValue(): JsonField = resellerContractValue + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of [Current]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** A builder for [Current]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(current: Current) = apply { + endingBefore = current.endingBefore + startingAt = current.startingAt + additionalProperties = current.additionalProperties.toMutableMap() + } - /** - * Returns a mutable builder for constructing an instance of [AddResellerRoyalty]. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** A builder for [AddResellerRoyalty]. */ - class Builder internal constructor() { + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - private var resellerType: JsonField? = null - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var awsAccountNumber: JsonField = JsonMissing.of() - private var awsOfferId: JsonField = JsonMissing.of() - private var awsPayerReferenceId: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var fraction: JsonField = JsonMissing.of() - private var gcpAccountId: JsonField = JsonMissing.of() - private var gcpOfferId: JsonField = JsonMissing.of() - private var netsuiteResellerId: JsonField = JsonMissing.of() - private var resellerContractValue: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - @JvmSynthetic - internal fun from(addResellerRoyalty: AddResellerRoyalty) = apply { - resellerType = addResellerRoyalty.resellerType - applicableProductIds = - addResellerRoyalty.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - addResellerRoyalty.applicableProductTags.map { it.toMutableList() } - awsAccountNumber = addResellerRoyalty.awsAccountNumber - awsOfferId = addResellerRoyalty.awsOfferId - awsPayerReferenceId = addResellerRoyalty.awsPayerReferenceId - endingBefore = addResellerRoyalty.endingBefore - fraction = addResellerRoyalty.fraction - gcpAccountId = addResellerRoyalty.gcpAccountId - gcpOfferId = addResellerRoyalty.gcpOfferId - netsuiteResellerId = addResellerRoyalty.netsuiteResellerId - resellerContractValue = addResellerRoyalty.resellerContractValue - startingAt = addResellerRoyalty.startingAt - additionalProperties = addResellerRoyalty.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - fun resellerType(resellerType: ResellerType) = - resellerType(JsonField.of(resellerType)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.resellerType] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerType] with a well-typed [ResellerType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun resellerType(resellerType: JsonField) = apply { - this.resellerType = resellerType - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun applicableProductIds(applicableProductIds: List) = - applicableProductIds(JsonField.of(applicableProductIds)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) + /** + * Returns an immutable instance of [Current]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Current = + Current( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Current = apply { + if (validated) { + return@apply } - } - fun applicableProductTags(applicableProductTags: List) = - applicableProductTags(JsonField.of(applicableProductTags)) + endingBefore() + startingAt() + validated = true + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - fun awsAccountNumber(awsAccountNumber: String) = - awsAccountNumber(JsonField.of(awsAccountNumber)) + return other is Current && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.awsAccountNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.awsAccountNumber] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun awsAccountNumber(awsAccountNumber: JsonField) = apply { - this.awsAccountNumber = awsAccountNumber - } + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) + } - fun awsOfferId(awsOfferId: String) = awsOfferId(JsonField.of(awsOfferId)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.awsOfferId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsOfferId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun awsOfferId(awsOfferId: JsonField) = apply { - this.awsOfferId = awsOfferId + override fun toString() = + "Current{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } - fun awsPayerReferenceId(awsPayerReferenceId: String) = - awsPayerReferenceId(JsonField.of(awsPayerReferenceId)) + class Next + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.awsPayerReferenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.awsPayerReferenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun awsPayerReferenceId(awsPayerReferenceId: JsonField) = apply { - this.awsPayerReferenceId = awsPayerReferenceId - } + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - fun endingBefore(endingBefore: OffsetDateTime?) = - endingBefore(JsonField.ofNullable(endingBefore)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ - fun endingBefore(endingBefore: Optional) = - endingBefore(endingBefore.getOrNull()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - fun fraction(fraction: Double) = fraction(JsonField.of(fraction)) + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Sets [Builder.fraction] to an arbitrary JSON value. - * - * You should usually call [Builder.fraction] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun fraction(fraction: JsonField) = apply { this.fraction = fraction } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun gcpAccountId(gcpAccountId: String) = gcpAccountId(JsonField.of(gcpAccountId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.gcpAccountId] to an arbitrary JSON value. - * - * You should usually call [Builder.gcpAccountId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gcpAccountId(gcpAccountId: JsonField) = apply { - this.gcpAccountId = gcpAccountId - } + fun toBuilder() = Builder().from(this) - fun gcpOfferId(gcpOfferId: String) = gcpOfferId(JsonField.of(gcpOfferId)) + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Next]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.gcpOfferId] to an arbitrary JSON value. - * - * You should usually call [Builder.gcpOfferId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun gcpOfferId(gcpOfferId: JsonField) = apply { - this.gcpOfferId = gcpOfferId - } + /** A builder for [Next]. */ + class Builder internal constructor() { - fun netsuiteResellerId(netsuiteResellerId: String) = - netsuiteResellerId(JsonField.of(netsuiteResellerId)) + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.netsuiteResellerId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteResellerId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun netsuiteResellerId(netsuiteResellerId: JsonField) = apply { - this.netsuiteResellerId = netsuiteResellerId - } + @JvmSynthetic + internal fun from(next: Next) = apply { + endingBefore = next.endingBefore + startingAt = next.startingAt + additionalProperties = next.additionalProperties.toMutableMap() + } - fun resellerContractValue(resellerContractValue: Double) = - resellerContractValue(JsonField.of(resellerContractValue)) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Sets [Builder.resellerContractValue] to an arbitrary JSON value. - * - * You should usually call [Builder.resellerContractValue] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun resellerContractValue(resellerContractValue: JsonField) = apply { - this.resellerContractValue = resellerContractValue - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns an immutable instance of [AddResellerRoyalty]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .resellerType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddResellerRoyalty = - AddResellerRoyalty( - checkRequired("resellerType", resellerType), - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an immutable instance of [Next]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Next = + Next( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - private var validated: Boolean = false + private var validated: Boolean = false - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AddResellerRoyalty = apply { - if (validated) { - return@apply - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Next = apply { + if (validated) { + return@apply + } - resellerType().validate() - applicableProductIds() - applicableProductTags() - awsAccountNumber() - awsOfferId() - awsPayerReferenceId() - endingBefore() - fraction() - gcpAccountId() - gcpOfferId() - netsuiteResellerId() - resellerContractValue() - startingAt() - validated = true - } + endingBefore() + startingAt() + validated = true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (resellerType.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (awsAccountNumber.asKnown().isPresent) 1 else 0) + - (if (awsOfferId.asKnown().isPresent) 1 else 0) + - (if (awsPayerReferenceId.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (fraction.asKnown().isPresent) 1 else 0) + - (if (gcpAccountId.asKnown().isPresent) 1 else 0) + - (if (gcpOfferId.asKnown().isPresent) 1 else 0) + - (if (netsuiteResellerId.asKnown().isPresent) 1 else 0) + - (if (resellerContractValue.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - class ResellerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is Next && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) + } - @JvmField val AWS = of("AWS") + override fun hashCode(): Int = hashCode - @JvmField val AWS_PRO_SERVICE = of("AWS_PRO_SERVICE") + override fun toString() = + "Next{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - @JvmField val GCP = of("GCP") + class Previous + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val GCP_PRO_SERVICE = of("GCP_PRO_SERVICE") + @JsonCreator + private constructor( + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(endingBefore, startingAt, mutableMapOf()) - @JvmStatic fun of(value: String) = ResellerType(JsonField.of(value)) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - /** An enum containing [ResellerType]'s known values. */ - enum class Known { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * An enum containing [ResellerType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResellerType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AWS, - AWS_PRO_SERVICE, - GCP, - GCP_PRO_SERVICE, /** - * An enum member indicating that [ResellerType] was instantiated with an - * unknown value. + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. */ - _UNKNOWN, - } + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AWS -> Value.AWS - AWS_PRO_SERVICE -> Value.AWS_PRO_SERVICE - GCP -> Value.GCP - GCP_PRO_SERVICE -> Value.GCP_PRO_SERVICE - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AWS -> Known.AWS - AWS_PRO_SERVICE -> Known.AWS_PRO_SERVICE - GCP -> Known.GCP - GCP_PRO_SERVICE -> Known.GCP_PRO_SERVICE - else -> throw MetronomeInvalidDataException("Unknown ResellerType: $value") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): ResellerType = apply { - if (validated) { - return@apply + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Previous]. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() } - known() - validated = true - } + /** A builder for [Previous]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun from(previous: Previous) = apply { + endingBefore = previous.endingBefore + startingAt = previous.startingAt + additionalProperties = previous.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - return other is ResellerType && value == other.value - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } + + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) + + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun hashCode() = value.hashCode() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString() = value.toString() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - return other is AddResellerRoyalty && - resellerType == other.resellerType && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - awsAccountNumber == other.awsAccountNumber && - awsOfferId == other.awsOfferId && - awsPayerReferenceId == other.awsPayerReferenceId && - endingBefore == other.endingBefore && - fraction == other.fraction && - gcpAccountId == other.gcpAccountId && - gcpOfferId == other.gcpOfferId && - netsuiteResellerId == other.netsuiteResellerId && - resellerContractValue == other.resellerContractValue && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private val hashCode: Int by lazy { - Objects.hash( - resellerType, - applicableProductIds, - applicableProductTags, - awsAccountNumber, - awsOfferId, - awsPayerReferenceId, - endingBefore, - fraction, - gcpAccountId, - gcpOfferId, - netsuiteResellerId, - resellerContractValue, - startingAt, - additionalProperties, - ) - } + /** + * Returns an immutable instance of [Previous]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Previous = + Previous( + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "AddResellerRoyalty{resellerType=$resellerType, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, awsAccountNumber=$awsAccountNumber, awsOfferId=$awsOfferId, awsPayerReferenceId=$awsPayerReferenceId, endingBefore=$endingBefore, fraction=$fraction, gcpAccountId=$gcpAccountId, gcpOfferId=$gcpOfferId, netsuiteResellerId=$netsuiteResellerId, resellerContractValue=$resellerContractValue, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Previous = apply { + if (validated) { + return@apply + } - class AddScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val product: JsonField, - private val schedule: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val additionalProperties: MutableMap, - ) { + endingBefore() + startingAt() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - ) : this(id, product, schedule, name, netsuiteSalesOrderId, mutableMapOf()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun product(): Product = product.getRequired("product") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun schedule(): SchedulePointInTime = schedule.getRequired("schedule") + return other is Previous && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** - * displayed on invoices - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + private val hashCode: Int by lazy { + Objects.hash(endingBefore, startingAt, additionalProperties) + } - /** - * This field's availability is dependent on your client's configuration. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + override fun toString() = + "Previous{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [product]. - * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [schedule]. - * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule + return other is BillingPeriods && + current == other.current && + next == other.next && + previous == other.previous && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + private val hashCode: Int by lazy { + Objects.hash(current, next, previous, additionalProperties) + } - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + override fun hashCode(): Int = hashCode - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun toString() = + "BillingPeriods{current=$current, next=$next, previous=$previous, additionalProperties=$additionalProperties}" } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + class CollectionSchedule + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns a mutable builder for constructing an instance of [AddScheduledCharge]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .id() - * .product() - * .schedule() - * ``` + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [AddScheduledCharge]. */ - class Builder internal constructor() { + companion object { - private var id: JsonField? = null - private var product: JsonField? = null - private var schedule: JsonField? = null - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ADVANCE = of("ADVANCE") - @JvmSynthetic - internal fun from(addScheduledCharge: AddScheduledCharge) = apply { - id = addScheduledCharge.id - product = addScheduledCharge.product - schedule = addScheduledCharge.schedule - name = addScheduledCharge.name - netsuiteSalesOrderId = addScheduledCharge.netsuiteSalesOrderId - additionalProperties = addScheduledCharge.additionalProperties.toMutableMap() + @JvmField val ARREARS = of("ARREARS") + + @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) } - fun id(id: String) = id(JsonField.of(id)) + /** An enum containing [CollectionSchedule]'s known values. */ + enum class Known { + ADVANCE, + ARREARS, + } /** - * Sets [Builder.id] to an arbitrary JSON value. + * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] + * member. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An instance of [CollectionSchedule] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun id(id: JsonField) = apply { this.id = id } - - fun product(product: Product) = product(JsonField.of(product)) + enum class Value { + ADVANCE, + ARREARS, + /** + * An enum member indicating that [CollectionSchedule] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.product] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun product(product: JsonField) = apply { this.product = product } - - fun schedule(schedule: SchedulePointInTime) = schedule(JsonField.of(schedule)) + fun value(): Value = + when (this) { + ADVANCE -> Value.ADVANCE + ARREARS -> Value.ARREARS + else -> Value._UNKNOWN + } /** - * Sets [Builder.schedule] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.schedule] with a well-typed - * [SchedulePointInTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - fun schedule(schedule: JsonField) = apply { - this.schedule = schedule - } - - /** displayed on invoices */ - fun name(name: String) = name(JsonField.of(name)) + fun known(): Known = + when (this) { + ADVANCE -> Known.ADVANCE + ARREARS -> Known.ARREARS + else -> + throw MetronomeInvalidDataException( + "Unknown CollectionSchedule: $value" + ) + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - fun name(name: JsonField) = apply { this.name = name } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** This field's availability is dependent on your client's configuration. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + private var validated: Boolean = false /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): CollectionSchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .product() - * .schedule() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddScheduledCharge = - AddScheduledCharge( - checkRequired("id", id), - checkRequired("product", product), - checkRequired("schedule", schedule), - name, - netsuiteSalesOrderId, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AddScheduledCharge = apply { - if (validated) { - return@apply + return other is CollectionSchedule && value == other.value } - id() - product().validate() - schedule().validate() - name() - netsuiteSalesOrderId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + override fun toString() = value.toString() + } - class Product + class Proration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, - private val name: JsonField, + private val invoiceBehavior: JsonField, + private val isProrated: JsonField, + private val rounding: JsonField, private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + @JsonCreator + private constructor( + @JsonProperty("invoice_behavior") + @ExcludeMissing + invoiceBehavior: JsonField = JsonMissing.of(), + @JsonProperty("is_prorated") + @ExcludeMissing + isProrated: JsonField = JsonMissing.of(), + @JsonProperty("rounding") + @ExcludeMissing + rounding: JsonField = JsonMissing.of(), + ) : this(invoiceBehavior, isProrated, rounding, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun id(): String = id.getRequired("id") + fun invoiceBehavior(): InvoiceBehavior = + invoiceBehavior.getRequired("invoice_behavior") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun name(): String = name.getRequired("name") + fun isProrated(): Boolean = isProrated.getRequired("is_prorated") /** - * Returns the raw JSON value of [id]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rounding(): Optional = rounding.getOptional("rounding") + + /** + * Returns the raw JSON value of [invoiceBehavior]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("invoice_behavior") + @ExcludeMissing + fun _invoiceBehavior(): JsonField = invoiceBehavior /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [isProrated]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * Unlike [isProrated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_prorated") + @ExcludeMissing + fun _isProrated(): JsonField = isProrated + + /** + * Returns the raw JSON value of [rounding]. + * + * Unlike [rounding], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("rounding") + @ExcludeMissing + fun _rounding(): JsonField = rounding @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -15073,52 +18884,70 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Product]. + * Returns a mutable builder for constructing an instance of [Proration]. * * The following fields are required: * ```java - * .id() - * .name() + * .invoiceBehavior() + * .isProrated() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Product]. */ + /** A builder for [Proration]. */ class Builder internal constructor() { - private var id: JsonField? = null - private var name: JsonField? = null + private var invoiceBehavior: JsonField? = null + private var isProrated: JsonField? = null + private var rounding: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() + internal fun from(proration: Proration) = apply { + invoiceBehavior = proration.invoiceBehavior + isProrated = proration.isProrated + rounding = proration.rounding + additionalProperties = proration.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = + invoiceBehavior(JsonField.of(invoiceBehavior)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.invoiceBehavior] with a well-typed + * [InvoiceBehavior] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun invoiceBehavior(invoiceBehavior: JsonField) = apply { + this.invoiceBehavior = invoiceBehavior + } - fun name(name: String) = name(JsonField.of(name)) + fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.isProrated] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value + * You should usually call [Builder.isProrated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isProrated(isProrated: JsonField) = apply { + this.isProrated = isProrated + } + + fun rounding(rounding: Rounding) = rounding(JsonField.of(rounding)) + + /** + * Sets [Builder.rounding] to an arbitrary JSON value. + * + * You should usually call [Builder.rounding] with a well-typed [Rounding] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun rounding(rounding: JsonField) = apply { this.rounding = rounding } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -15143,22 +18972,23 @@ private constructor( } /** - * Returns an immutable instance of [Product]. + * Returns an immutable instance of [Proration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() - * .name() + * .invoiceBehavior() + * .isProrated() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), + fun build(): Proration = + Proration( + checkRequired("invoiceBehavior", invoiceBehavior), + checkRequired("isProrated", isProrated), + rounding, additionalProperties.toMutableMap(), ) } @@ -15175,13 +19005,14 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Product = apply { + fun validate(): Proration = apply { if (validated) { return@apply } - id() - name() + invoiceBehavior().validate() + isProrated() + rounding().ifPresent { it.validate() } validated = true } @@ -15189,1407 +19020,1317 @@ private constructor( try { validate() true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddScheduledCharge && - id == other.id && - product == other.product && - schedule == other.schedule && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - product, - schedule, - name, - netsuiteSalesOrderId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddScheduledCharge{id=$id, product=$product, schedule=$schedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, additionalProperties=$additionalProperties}" - } - - class AddSubscription - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val billingPeriods: JsonField, - private val collectionSchedule: JsonField, - private val proration: JsonField, - private val quantityManagementMode: JsonField, - private val quantitySchedule: JsonField>, - private val startingAt: JsonField, - private val subscriptionRate: JsonField, - private val id: JsonField, - private val customFields: JsonField, - private val description: JsonField, - private val endingBefore: JsonField, - private val fiatCreditTypeId: JsonField, - private val name: JsonField, - private val seatConfig: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("billing_periods") - @ExcludeMissing - billingPeriods: JsonField = JsonMissing.of(), - @JsonProperty("collection_schedule") - @ExcludeMissing - collectionSchedule: JsonField = JsonMissing.of(), - @JsonProperty("proration") - @ExcludeMissing - proration: JsonField = JsonMissing.of(), - @JsonProperty("quantity_management_mode") - @ExcludeMissing - quantityManagementMode: JsonField = JsonMissing.of(), - @JsonProperty("quantity_schedule") - @ExcludeMissing - quantitySchedule: JsonField> = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("subscription_rate") - @ExcludeMissing - subscriptionRate: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fiatCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("seat_config") - @ExcludeMissing - seatConfig: JsonField = JsonMissing.of(), - ) : this( - billingPeriods, - collectionSchedule, - proration, - quantityManagementMode, - quantitySchedule, - startingAt, - subscriptionRate, - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - mutableMapOf(), - ) + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Previous, current, and next billing periods for the subscription. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun billingPeriods(): BillingPeriods = billingPeriods.getRequired("billing_periods") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + + (if (isProrated.asKnown().isPresent) 1 else 0) + + (rounding.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun collectionSchedule(): CollectionSchedule = - collectionSchedule.getRequired("collection_schedule") + class InvoiceBehavior + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun proration(): Proration = proration.getRequired("proration") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per - * seat. `seat_config` must be provided with this option. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun quantityManagementMode(): QuantityManagementMode = - quantityManagementMode.getRequired("quantity_management_mode") + companion object { - /** - * List of quantity schedule items for the subscription. Only includes the current - * quantity and future quantity changes. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun quantitySchedule(): List = - quantitySchedule.getRequired("quantity_schedule") + @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + @JvmField + val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subscriptionRate(): SubscriptionRate = - subscriptionRate.getRequired("subscription_rate") + @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + /** An enum containing [InvoiceBehavior]'s known values. */ + enum class Known { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + } - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + /** + * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BILL_IMMEDIATELY, + BILL_ON_NEXT_COLLECTION_DATE, + /** + * An enum member indicating that [InvoiceBehavior] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + else -> Value._UNKNOWN + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY + BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + else -> + throw MetronomeInvalidDataException( + "Unknown InvoiceBehavior: $value" + ) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun fiatCreditTypeId(): Optional = - fiatCreditTypeId.getOptional("fiat_credit_type_id") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + private var validated: Boolean = false - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun seatConfig(): Optional = seatConfig.getOptional("seat_config") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): InvoiceBehavior = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [billingPeriods]. - * - * Unlike [billingPeriods], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_periods") - @ExcludeMissing - fun _billingPeriods(): JsonField = billingPeriods + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceBehavior && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [collectionSchedule]. - * - * Unlike [collectionSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_schedule") - @ExcludeMissing - fun _collectionSchedule(): JsonField = collectionSchedule + class Rounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [proration]. - * - * Unlike [proration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("proration") - @ExcludeMissing - fun _proration(): JsonField = proration + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - /** - * Returns the raw JSON value of [quantityManagementMode]. - * - * Unlike [quantityManagementMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_management_mode") - @ExcludeMissing - fun _quantityManagementMode(): JsonField = - quantityManagementMode + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** - * Returns the raw JSON value of [quantitySchedule]. - * - * Unlike [quantitySchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity_schedule") - @ExcludeMissing - fun _quantitySchedule(): JsonField> = quantitySchedule + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - /** - * Returns the raw JSON value of [subscriptionRate]. - * - * Unlike [subscriptionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_rate") - @ExcludeMissing - fun _subscriptionRate(): JsonField = subscriptionRate + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + companion object { - /** - * Returns the raw JSON value of [fiatCreditTypeId]. - * - * Unlike [fiatCreditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fiat_credit_type_id") - @ExcludeMissing - fun _fiatCreditTypeId(): JsonField = fiatCreditTypeId + /** + * Returns a mutable builder for constructing an instance of [Rounding]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** A builder for [Rounding]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [seatConfig]. - * - * Unlike [seatConfig], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("seat_config") - @ExcludeMissing - fun _seatConfig(): JsonField = seatConfig + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmSynthetic + internal fun from(rounding: Rounding) = apply { + decimalPlaces = rounding.decimalPlaces + roundingMethod = rounding.roundingMethod + additionalProperties = rounding.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - companion object { + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - /** - * Returns a mutable builder for constructing an instance of [AddSubscription]. - * - * The following fields are required: - * ```java - * .billingPeriods() - * .collectionSchedule() - * .proration() - * .quantityManagementMode() - * .quantitySchedule() - * .startingAt() - * .subscriptionRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - /** A builder for [AddSubscription]. */ - class Builder internal constructor() { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var billingPeriods: JsonField? = null - private var collectionSchedule: JsonField? = null - private var proration: JsonField? = null - private var quantityManagementMode: JsonField? = null - private var quantitySchedule: JsonField>? = null - private var startingAt: JsonField? = null - private var subscriptionRate: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var customFields: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var fiatCreditTypeId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var seatConfig: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmSynthetic - internal fun from(addSubscription: AddSubscription) = apply { - billingPeriods = addSubscription.billingPeriods - collectionSchedule = addSubscription.collectionSchedule - proration = addSubscription.proration - quantityManagementMode = addSubscription.quantityManagementMode - quantitySchedule = addSubscription.quantitySchedule.map { it.toMutableList() } - startingAt = addSubscription.startingAt - subscriptionRate = addSubscription.subscriptionRate - id = addSubscription.id - customFields = addSubscription.customFields - description = addSubscription.description - endingBefore = addSubscription.endingBefore - fiatCreditTypeId = addSubscription.fiatCreditTypeId - name = addSubscription.name - seatConfig = addSubscription.seatConfig - additionalProperties = addSubscription.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Previous, current, and next billing periods for the subscription. */ - fun billingPeriods(billingPeriods: BillingPeriods) = - billingPeriods(JsonField.of(billingPeriods)) + /** + * Returns an immutable instance of [Rounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rounding = + Rounding( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.billingPeriods] to an arbitrary JSON value. - * - * You should usually call [Builder.billingPeriods] with a well-typed - * [BillingPeriods] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun billingPeriods(billingPeriods: JsonField) = apply { - this.billingPeriods = billingPeriods - } + private var validated: Boolean = false - fun collectionSchedule(collectionSchedule: CollectionSchedule) = - collectionSchedule(JsonField.of(collectionSchedule)) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Rounding = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.collectionSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionSchedule] with a well-typed - * [CollectionSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun collectionSchedule(collectionSchedule: JsonField) = apply { - this.collectionSchedule = collectionSchedule - } + decimalPlaces() + roundingMethod().validate() + validated = true + } - fun proration(proration: Proration) = proration(JsonField.of(proration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Sets [Builder.proration] to an arbitrary JSON value. - * - * You should usually call [Builder.proration] with a well-typed [Proration] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun proration(proration: JsonField) = apply { - this.proration = proration - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - /** - * Determines how the subscription's quantity is controlled. Defaults to - * QUANTITY_ONLY. **QUANTITY_ONLY**: The subscription quantity is specified directly - * on the subscription. `initial_quantity` must be provided with this option. - * Compatible with recurring commits/credits that use POOLED allocation. - * **SEAT_BASED**: Use when you want to pass specific seat identifiers (e.g. add - * user_123) to increment and decrement a subscription quantity, rather than - * directly providing the quantity. You must use a **SEAT_BASED** subscription to - * use a linked recurring credit with an allocation per seat. `seat_config` must be - * provided with this option. - */ - fun quantityManagementMode(quantityManagementMode: QuantityManagementMode) = - quantityManagementMode(JsonField.of(quantityManagementMode)) + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.quantityManagementMode] to an arbitrary JSON value. - * - * You should usually call [Builder.quantityManagementMode] with a well-typed - * [QuantityManagementMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantityManagementMode( - quantityManagementMode: JsonField - ) = apply { this.quantityManagementMode = quantityManagementMode } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * List of quantity schedule items for the subscription. Only includes the current - * quantity and future quantity changes. - */ - fun quantitySchedule(quantitySchedule: List) = - quantitySchedule(JsonField.of(quantitySchedule)) + companion object { - /** - * Sets [Builder.quantitySchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.quantitySchedule] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun quantitySchedule(quantitySchedule: JsonField>) = apply { - this.quantitySchedule = quantitySchedule.map { it.toMutableList() } - } + @JvmField val HALF_UP = of("HALF_UP") - /** - * Adds a single [QuantitySchedule] to [Builder.quantitySchedule]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addQuantitySchedule(quantitySchedule: QuantitySchedule) = apply { - this.quantitySchedule = - (this.quantitySchedule ?: JsonField.of(mutableListOf())).also { - checkKnown("quantitySchedule", it).add(quantitySchedule) - } - } + @JvmField val FLOOR = of("FLOOR") - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + @JvmField val CEILING = of("CEILING") - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - fun subscriptionRate(subscriptionRate: SubscriptionRate) = - subscriptionRate(JsonField.of(subscriptionRate)) + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** - * Sets [Builder.subscriptionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionRate] with a well-typed - * [SubscriptionRate] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun subscriptionRate(subscriptionRate: JsonField) = apply { - this.subscriptionRate = subscriptionRate - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - fun id(id: String) = id(JsonField.of(id)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = - customFields(JsonField.of(customFields)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - fun description(description: String) = description(JsonField.of(description)) + known() + validated = true + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun fiatCreditTypeId(fiatCreditTypeId: String) = - fiatCreditTypeId(JsonField.of(fiatCreditTypeId)) + return other is RoundingMethod && value == other.value + } - /** - * Sets [Builder.fiatCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.fiatCreditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun fiatCreditTypeId(fiatCreditTypeId: JsonField) = apply { - this.fiatCreditTypeId = fiatCreditTypeId - } + override fun hashCode() = value.hashCode() - fun name(name: String) = name(JsonField.of(name)) + override fun toString() = value.toString() + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun seatConfig(seatConfig: SeatConfig) = seatConfig(JsonField.of(seatConfig)) + return other is Rounding && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.seatConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.seatConfig] with a well-typed [SeatConfig] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun seatConfig(seatConfig: JsonField) = apply { - this.seatConfig = seatConfig - } + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode(): Int = hashCode - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun toString() = + "Rounding{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + return other is Proration && + invoiceBehavior == other.invoiceBehavior && + isProrated == other.isProrated && + rounding == other.rounding && + additionalProperties == other.additionalProperties } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private val hashCode: Int by lazy { + Objects.hash(invoiceBehavior, isProrated, rounding, additionalProperties) } - /** - * Returns an immutable instance of [AddSubscription]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingPeriods() - * .collectionSchedule() - * .proration() - * .quantityManagementMode() - * .quantitySchedule() - * .startingAt() - * .subscriptionRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddSubscription = - AddSubscription( - checkRequired("billingPeriods", billingPeriods), - checkRequired("collectionSchedule", collectionSchedule), - checkRequired("proration", proration), - checkRequired("quantityManagementMode", quantityManagementMode), - checkRequired("quantitySchedule", quantitySchedule).map { - it.toImmutable() - }, - checkRequired("startingAt", startingAt), - checkRequired("subscriptionRate", subscriptionRate), - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - additionalProperties.toMutableMap(), - ) - } + override fun hashCode(): Int = hashCode - private var validated: Boolean = false + override fun toString() = + "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, rounding=$rounding, additionalProperties=$additionalProperties}" + } /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. + * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. + * **QUANTITY_ONLY**: The subscription quantity is specified directly on the + * subscription. `initial_quantity` must be provided with this option. Compatible with + * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you + * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement + * a subscription quantity, rather than directly providing the quantity. You must use a + * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per + * seat. `seat_config` must be provided with this option. */ - fun validate(): AddSubscription = apply { - if (validated) { - return@apply - } + class QuantityManagementMode + @JsonCreator + private constructor(private val value: JsonField) : Enum { - billingPeriods().validate() - collectionSchedule().validate() - proration().validate() - quantityManagementMode().validate() - quantitySchedule().forEach { it.validate() } - startingAt() - subscriptionRate().validate() - id() - customFields().ifPresent { it.validate() } - description() - endingBefore() - fiatCreditTypeId() - name() - seatConfig().ifPresent { it.validate() } - validated = true - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + companion object { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (billingPeriods.asKnown().getOrNull()?.validity() ?: 0) + - (collectionSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (proration.asKnown().getOrNull()?.validity() ?: 0) + - (quantityManagementMode.asKnown().getOrNull()?.validity() ?: 0) + - (quantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (subscriptionRate.asKnown().getOrNull()?.validity() ?: 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (fiatCreditTypeId.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (seatConfig.asKnown().getOrNull()?.validity() ?: 0) + @JvmField val SEAT_BASED = of("SEAT_BASED") - /** Previous, current, and next billing periods for the subscription. */ - class BillingPeriods - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val current: JsonField, - private val next: JsonField, - private val previous: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") - @JsonCreator - private constructor( - @JsonProperty("current") - @ExcludeMissing - current: JsonField = JsonMissing.of(), - @JsonProperty("next") @ExcludeMissing next: JsonField = JsonMissing.of(), - @JsonProperty("previous") - @ExcludeMissing - previous: JsonField = JsonMissing.of(), - ) : this(current, next, previous, mutableMapOf()) + @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun current(): Optional = current.getOptional("current") + /** An enum containing [QuantityManagementMode]'s known values. */ + enum class Known { + SEAT_BASED, + QUANTITY_ONLY, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * An enum containing [QuantityManagementMode]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [QuantityManagementMode] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun next(): Optional = next.getOptional("next") + enum class Value { + SEAT_BASED, + QUANTITY_ONLY, + /** + * An enum member indicating that [QuantityManagementMode] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun previous(): Optional = previous.getOptional("previous") + fun value(): Value = + when (this) { + SEAT_BASED -> Value.SEAT_BASED + QUANTITY_ONLY -> Value.QUANTITY_ONLY + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [current]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [current], this method doesn't throw if the JSON field has an unexpected - * type. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. */ - @JsonProperty("current") - @ExcludeMissing - fun _current(): JsonField = current + fun known(): Known = + when (this) { + SEAT_BASED -> Known.SEAT_BASED + QUANTITY_ONLY -> Known.QUANTITY_ONLY + else -> + throw MetronomeInvalidDataException( + "Unknown QuantityManagementMode: $value" + ) + } /** - * Returns the raw JSON value of [next]. + * Returns this class instance's primitive wire representation. * - * Unlike [next], this method doesn't throw if the JSON field has an unexpected - * type. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. */ - @JsonProperty("next") @ExcludeMissing fun _next(): JsonField = next + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [previous]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [previous], this method doesn't throw if the JSON field has an unexpected - * type. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JsonProperty("previous") - @ExcludeMissing - fun _previous(): JsonField = previous - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + fun validate(): QuantityManagementMode = apply { + if (validated) { + return@apply + } - /** - * Returns a mutable builder for constructing an instance of [BillingPeriods]. - */ - @JvmStatic fun builder() = Builder() + known() + validated = true } - /** A builder for [BillingPeriods]. */ - class Builder internal constructor() { - - private var current: JsonField = JsonMissing.of() - private var next: JsonField = JsonMissing.of() - private var previous: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingPeriods: BillingPeriods) = apply { - current = billingPeriods.current - next = billingPeriods.next - previous = billingPeriods.previous - additionalProperties = billingPeriods.additionalProperties.toMutableMap() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - fun current(current: Current) = current(JsonField.of(current)) - - /** - * Sets [Builder.current] to an arbitrary JSON value. - * - * You should usually call [Builder.current] with a well-typed [Current] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun current(current: JsonField) = apply { this.current = current } - - fun next(next: Next) = next(JsonField.of(next)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Sets [Builder.next] to an arbitrary JSON value. - * - * You should usually call [Builder.next] with a well-typed [Next] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun next(next: JsonField) = apply { this.next = next } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun previous(previous: Previous) = previous(JsonField.of(previous)) + return other is QuantityManagementMode && value == other.value + } - /** - * Sets [Builder.previous] to an arbitrary JSON value. - * - * You should usually call [Builder.previous] with a well-typed [Previous] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun previous(previous: JsonField) = apply { this.previous = previous } + override fun hashCode() = value.hashCode() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun toString() = value.toString() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class QuantitySchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val quantity: JsonField, + private val startingAt: JsonField, + private val endingBefore: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + ) : this(quantity, startingAt, endingBefore, mutableMapOf()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun quantity(): Double = quantity.getRequired("quantity") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * Returns an immutable instance of [BillingPeriods]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BillingPeriods = - BillingPeriods(current, next, previous, additionalProperties.toMutableMap()) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - private var validated: Boolean = false + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Returns the raw JSON value of [startingAt]. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun validate(): BillingPeriods = apply { - if (validated) { - return@apply - } - - current().ifPresent { it.validate() } - next().ifPresent { it.validate() } - previous().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [endingBefore]. * - * Used for best match union deserialization. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = - (current.asKnown().getOrNull()?.validity() ?: 0) + - (next.asKnown().getOrNull()?.validity() ?: 0) + - (previous.asKnown().getOrNull()?.validity() ?: 0) - - class Current - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - @JsonCreator - private constructor( - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + companion object { /** - * Returns the raw JSON value of [startingAt]. + * Returns a mutable builder for constructing an instance of [QuantitySchedule]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [QuantitySchedule]. */ + class Builder internal constructor() { - companion object { + private var quantity: JsonField? = null + private var startingAt: JsonField? = null + private var endingBefore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a mutable builder for constructing an instance of [Current]. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(quantitySchedule: QuantitySchedule) = apply { + quantity = quantitySchedule.quantity + startingAt = quantitySchedule.startingAt + endingBefore = quantitySchedule.endingBefore + additionalProperties = quantitySchedule.additionalProperties.toMutableMap() } - /** A builder for [Current]. */ - class Builder internal constructor() { - - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(current: Current) = apply { - endingBefore = current.endingBefore - startingAt = current.startingAt - additionalProperties = current.additionalProperties.toMutableMap() - } - - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) - - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) - - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Returns an immutable instance of [Current]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Current = - Current( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Current = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - endingBefore() - startingAt() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [QuantitySchedule]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .quantity() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + fun build(): QuantitySchedule = + QuantitySchedule( + checkRequired("quantity", quantity), + checkRequired("startingAt", startingAt), + endingBefore, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Current && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): QuantitySchedule = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) + quantity() + startingAt() + endingBefore() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) - override fun toString() = - "Current{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QuantitySchedule && + quantity == other.quantity && + startingAt == other.startingAt && + endingBefore == other.endingBefore && + additionalProperties == other.additionalProperties } - class Next - @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private val hashCode: Int by lazy { + Objects.hash(quantity, startingAt, endingBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + } + + class SubscriptionRate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val billingFrequency: JsonField, + private val product: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonProperty("billing_frequency") + @ExcludeMissing + billingFrequency: JsonField = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + product: JsonField = JsonMissing.of(), + ) : this(billingFrequency, product, mutableMapOf()) - @JsonCreator - private constructor( - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun billingFrequency(): BillingFrequency = + billingFrequency.getRequired("billing_frequency") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun product(): Product = product.getRequired("product") + + /** + * Returns the raw JSON value of [billingFrequency]. + * + * Unlike [billingFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_frequency") + @ExcludeMissing + fun _billingFrequency(): JsonField = billingFrequency + + /** + * Returns the raw JSON value of [product]. + * + * Unlike [product], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product") + @ExcludeMissing + fun _product(): JsonField = product + + @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 { /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * Returns a mutable builder for constructing an instance of [SubscriptionRate]. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionRate]. */ + class Builder internal constructor() { + + private var billingFrequency: JsonField? = null + private var product: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionRate: SubscriptionRate) = apply { + billingFrequency = subscriptionRate.billingFrequency + product = subscriptionRate.product + additionalProperties = subscriptionRate.additionalProperties.toMutableMap() + } + + fun billingFrequency(billingFrequency: BillingFrequency) = + billingFrequency(JsonField.of(billingFrequency)) /** - * Returns the raw JSON value of [endingBefore]. + * Sets [Builder.billingFrequency] to an arbitrary JSON value. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.billingFrequency] with a well-typed + * [BillingFrequency] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun billingFrequency(billingFrequency: JsonField) = apply { + this.billingFrequency = billingFrequency + } + + fun product(product: Product) = product(JsonField.of(product)) /** - * Returns the raw JSON value of [startingAt]. + * Sets [Builder.product] to an arbitrary JSON value. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.product] with a well-typed [Product] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun product(product: JsonField) = apply { this.product = product } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun toBuilder() = Builder().from(this) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - companion object { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns a mutable builder for constructing an instance of [Next]. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Returns an immutable instance of [SubscriptionRate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .billingFrequency() + * .product() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionRate = + SubscriptionRate( + checkRequired("billingFrequency", billingFrequency), + checkRequired("product", product), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SubscriptionRate = apply { + if (validated) { + return@apply } - /** A builder for [Next]. */ - class Builder internal constructor() { + billingFrequency().validate() + product().validate() + validated = true + } - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmSynthetic - internal fun from(next: Next) = apply { - endingBefore = next.endingBefore - startingAt = next.startingAt - additionalProperties = next.additionalProperties.toMutableMap() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + + (product.asKnown().getOrNull()?.validity() ?: 0) - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + class BillingFrequency + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + companion object { - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + @JvmField val MONTHLY = of("MONTHLY") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val QUARTERLY = of("QUARTERLY") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val ANNUAL = of("ANNUAL") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val WEEKLY = of("WEEKLY") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [BillingFrequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, + } + /** + * An enum containing [BillingFrequency]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BillingFrequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTHLY, + QUARTERLY, + ANNUAL, + WEEKLY, /** - * Returns an immutable instance of [Next]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An enum member indicating that [BillingFrequency] was instantiated with + * an unknown value. */ - fun build(): Next = - Next( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) + _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException( + "Unknown BillingFrequency: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + private var validated: Boolean = false /** @@ -16602,13 +20343,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Next = apply { + fun validate(): BillingFrequency = apply { if (validated) { return@apply } - endingBefore() - startingAt() + known() validated = true } @@ -16627,82 +20367,68 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Next && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) + return other is BillingFrequency && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Next{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Previous + class Product @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val id: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("ending_before") + @JsonProperty("id") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(endingBefore, startingAt, mutableMapOf()) + name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + fun id(): String = id.getRequired("id") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [id]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [name]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -16719,59 +20445,53 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Previous]. + * Returns a mutable builder for constructing an instance of [Product]. * * The following fields are required: * ```java - * .endingBefore() - * .startingAt() + * .id() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Previous]. */ + /** A builder for [Product]. */ class Builder internal constructor() { - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(previous: Previous) = apply { - endingBefore = previous.endingBefore - startingAt = previous.startingAt - additionalProperties = previous.additionalProperties.toMutableMap() + internal fun from(product: Product) = apply { + id = product.id + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun id(id: JsonField) = apply { this.id = id } - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -16796,22 +20516,22 @@ private constructor( } /** - * Returns an immutable instance of [Previous]. + * Returns an immutable instance of [Product]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .endingBefore() - * .startingAt() + * .id() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Previous = - Previous( - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -16819,286 +20539,143 @@ private constructor( private var validated: Boolean = false /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Previous = apply { - if (validated) { - return@apply - } - - endingBefore() - startingAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Previous && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endingBefore, startingAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Previous{endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BillingPeriods && - current == other.current && - next == other.next && - previous == other.previous && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(current, next, previous, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingPeriods{current=$current, next=$next, previous=$previous, additionalProperties=$additionalProperties}" - } - - class CollectionSchedule - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ADVANCE = of("ADVANCE") - - @JvmField val ARREARS = of("ARREARS") - - @JvmStatic fun of(value: String) = CollectionSchedule(JsonField.of(value)) - } - - /** An enum containing [CollectionSchedule]'s known values. */ - enum class Known { - ADVANCE, - ARREARS, - } - - /** - * An enum containing [CollectionSchedule]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionSchedule] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADVANCE, - ARREARS, - /** - * An enum member indicating that [CollectionSchedule] was instantiated with an - * unknown value. + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - _UNKNOWN, - } + fun validate(): Product = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADVANCE -> Value.ADVANCE - ARREARS -> Value.ARREARS - else -> Value._UNKNOWN + id() + name() + validated = true } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ADVANCE -> Known.ADVANCE - ARREARS -> Known.ARREARS - else -> - throw MetronomeInvalidDataException( - "Unknown CollectionSchedule: $value" - ) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): CollectionSchedule = apply { - if (validated) { - return@apply + return other is Product && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(id, name, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CollectionSchedule && value == other.value + return other is SubscriptionRate && + billingFrequency == other.billingFrequency && + product == other.product && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(billingFrequency, product, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" } - class Proration + class BillingCycleConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val invoiceBehavior: JsonField, - private val isProrated: JsonField, + private val anchorDate: JsonField, + private val invoicePlacement: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("invoice_behavior") + @JsonProperty("anchor_date") @ExcludeMissing - invoiceBehavior: JsonField = JsonMissing.of(), - @JsonProperty("is_prorated") + anchorDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_placement") @ExcludeMissing - isProrated: JsonField = JsonMissing.of(), - ) : this(invoiceBehavior, isProrated, mutableMapOf()) + invoicePlacement: JsonField = JsonMissing.of(), + ) : this(anchorDate, invoicePlacement, mutableMapOf()) /** + * The date this subscription's billing cycle is anchored to. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun invoiceBehavior(): InvoiceBehavior = - invoiceBehavior.getRequired("invoice_behavior") + fun anchorDate(): OffsetDateTime = anchorDate.getRequired("anchor_date") /** + * Controls whether this subscription consolidates onto usage invoices or gets its + * own scheduled invoice. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun isProrated(): Boolean = isProrated.getRequired("is_prorated") + fun invoicePlacement(): InvoicePlacement = + invoicePlacement.getRequired("invoice_placement") /** - * Returns the raw JSON value of [invoiceBehavior]. + * Returns the raw JSON value of [anchorDate]. * - * Unlike [invoiceBehavior], this method doesn't throw if the JSON field has an + * Unlike [anchorDate], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("invoice_behavior") + @JsonProperty("anchor_date") @ExcludeMissing - fun _invoiceBehavior(): JsonField = invoiceBehavior + fun _anchorDate(): JsonField = anchorDate /** - * Returns the raw JSON value of [isProrated]. + * Returns the raw JSON value of [invoicePlacement]. * - * Unlike [isProrated], this method doesn't throw if the JSON field has an + * Unlike [invoicePlacement], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("is_prorated") + @JsonProperty("invoice_placement") @ExcludeMissing - fun _isProrated(): JsonField = isProrated + fun _invoicePlacement(): JsonField = invoicePlacement @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17115,56 +20692,64 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Proration]. + * Returns a mutable builder for constructing an instance of + * [BillingCycleConfig]. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .anchorDate() + * .invoicePlacement() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Proration]. */ + /** A builder for [BillingCycleConfig]. */ class Builder internal constructor() { - private var invoiceBehavior: JsonField? = null - private var isProrated: JsonField? = null + private var anchorDate: JsonField? = null + private var invoicePlacement: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(proration: Proration) = apply { - invoiceBehavior = proration.invoiceBehavior - isProrated = proration.isProrated - additionalProperties = proration.additionalProperties.toMutableMap() + internal fun from(billingCycleConfig: BillingCycleConfig) = apply { + anchorDate = billingCycleConfig.anchorDate + invoicePlacement = billingCycleConfig.invoicePlacement + additionalProperties = + billingCycleConfig.additionalProperties.toMutableMap() } - fun invoiceBehavior(invoiceBehavior: InvoiceBehavior) = - invoiceBehavior(JsonField.of(invoiceBehavior)) + /** The date this subscription's billing cycle is anchored to. */ + fun anchorDate(anchorDate: OffsetDateTime) = + anchorDate(JsonField.of(anchorDate)) /** - * Sets [Builder.invoiceBehavior] to an arbitrary JSON value. + * Sets [Builder.anchorDate] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceBehavior] with a well-typed - * [InvoiceBehavior] value instead. This method is primarily for setting the + * You should usually call [Builder.anchorDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun invoiceBehavior(invoiceBehavior: JsonField) = apply { - this.invoiceBehavior = invoiceBehavior + fun anchorDate(anchorDate: JsonField) = apply { + this.anchorDate = anchorDate } - fun isProrated(isProrated: Boolean) = isProrated(JsonField.of(isProrated)) + /** + * Controls whether this subscription consolidates onto usage invoices or gets + * its own scheduled invoice. + */ + fun invoicePlacement(invoicePlacement: InvoicePlacement) = + invoicePlacement(JsonField.of(invoicePlacement)) /** - * Sets [Builder.isProrated] to an arbitrary JSON value. + * Sets [Builder.invoicePlacement] to an arbitrary JSON value. * - * You should usually call [Builder.isProrated] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.invoicePlacement] with a well-typed + * [InvoicePlacement] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun isProrated(isProrated: JsonField) = apply { - this.isProrated = isProrated + fun invoicePlacement(invoicePlacement: JsonField) = apply { + this.invoicePlacement = invoicePlacement } fun additionalProperties(additionalProperties: Map) = apply { @@ -17190,22 +20775,22 @@ private constructor( } /** - * Returns an immutable instance of [Proration]. + * Returns an immutable instance of [BillingCycleConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .invoiceBehavior() - * .isProrated() + * .anchorDate() + * .invoicePlacement() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Proration = - Proration( - checkRequired("invoiceBehavior", invoiceBehavior), - checkRequired("isProrated", isProrated), + fun build(): BillingCycleConfig = + BillingCycleConfig( + checkRequired("anchorDate", anchorDate), + checkRequired("invoicePlacement", invoicePlacement), additionalProperties.toMutableMap(), ) } @@ -17222,13 +20807,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Proration = apply { + fun validate(): BillingCycleConfig = apply { if (validated) { return@apply } - invoiceBehavior().validate() - isProrated() + anchorDate() + invoicePlacement().validate() validated = true } @@ -17248,10 +20833,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (invoiceBehavior.asKnown().getOrNull()?.validity() ?: 0) + - (if (isProrated.asKnown().isPresent) 1 else 0) + (if (anchorDate.asKnown().isPresent) 1 else 0) + + (invoicePlacement.asKnown().getOrNull()?.validity() ?: 0) - class InvoiceBehavior + /** + * Controls whether this subscription consolidates onto usage invoices or gets its + * own scheduled invoice. + */ + class InvoicePlacement @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17268,25 +20857,24 @@ private constructor( companion object { - @JvmField val BILL_IMMEDIATELY = of("BILL_IMMEDIATELY") + @JvmField val ON_SCHEDULED_INVOICE = of("ON_SCHEDULED_INVOICE") - @JvmField - val BILL_ON_NEXT_COLLECTION_DATE = of("BILL_ON_NEXT_COLLECTION_DATE") + @JvmField val ON_USAGE_INVOICE = of("ON_USAGE_INVOICE") - @JvmStatic fun of(value: String) = InvoiceBehavior(JsonField.of(value)) + @JvmStatic fun of(value: String) = InvoicePlacement(JsonField.of(value)) } - /** An enum containing [InvoiceBehavior]'s known values. */ + /** An enum containing [InvoicePlacement]'s known values. */ enum class Known { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, } /** - * An enum containing [InvoiceBehavior]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [InvoicePlacement]'s known values, as well as an + * [_UNKNOWN] member. * - * An instance of [InvoiceBehavior] can contain an unknown value in a couple of + * An instance of [InvoicePlacement] can contain an unknown value in a couple of * cases: * - It was deserialized from data that doesn't match any known member. For * example, if the SDK is on an older version than the API, then the API may @@ -17294,11 +20882,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BILL_IMMEDIATELY, - BILL_ON_NEXT_COLLECTION_DATE, + ON_SCHEDULED_INVOICE, + ON_USAGE_INVOICE, /** - * An enum member indicating that [InvoiceBehavior] was instantiated with an - * unknown value. + * An enum member indicating that [InvoicePlacement] was instantiated with + * an unknown value. */ _UNKNOWN, } @@ -17312,8 +20900,8 @@ private constructor( */ fun value(): Value = when (this) { - BILL_IMMEDIATELY -> Value.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Value.BILL_ON_NEXT_COLLECTION_DATE + ON_SCHEDULED_INVOICE -> Value.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Value.ON_USAGE_INVOICE else -> Value._UNKNOWN } @@ -17328,11 +20916,11 @@ private constructor( */ fun known(): Known = when (this) { - BILL_IMMEDIATELY -> Known.BILL_IMMEDIATELY - BILL_ON_NEXT_COLLECTION_DATE -> Known.BILL_ON_NEXT_COLLECTION_DATE + ON_SCHEDULED_INVOICE -> Known.ON_SCHEDULED_INVOICE + ON_USAGE_INVOICE -> Known.ON_USAGE_INVOICE else -> throw MetronomeInvalidDataException( - "Unknown InvoiceBehavior: $value" + "Unknown InvoicePlacement: $value" ) } @@ -17362,7 +20950,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): InvoiceBehavior = apply { + fun validate(): InvoicePlacement = apply { if (validated) { return@apply } @@ -17393,7 +20981,7 @@ private constructor( return true } - return other is InvoiceBehavior && value == other.value + return other is InvoicePlacement && value == other.value } override fun hashCode() = value.hashCode() @@ -17406,129 +20994,82 @@ private constructor( return true } - return other is Proration && - invoiceBehavior == other.invoiceBehavior && - isProrated == other.isProrated && + return other is BillingCycleConfig && + anchorDate == other.anchorDate && + invoicePlacement == other.invoicePlacement && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(invoiceBehavior, isProrated, additionalProperties) + Objects.hash(anchorDate, invoicePlacement, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Proration{invoiceBehavior=$invoiceBehavior, isProrated=$isProrated, additionalProperties=$additionalProperties}" - } - - /** - * Determines how the subscription's quantity is controlled. Defaults to QUANTITY_ONLY. - * **QUANTITY_ONLY**: The subscription quantity is specified directly on the - * subscription. `initial_quantity` must be provided with this option. Compatible with - * recurring commits/credits that use POOLED allocation. **SEAT_BASED**: Use when you - * want to pass specific seat identifiers (e.g. add user_123) to increment and decrement - * a subscription quantity, rather than directly providing the quantity. You must use a - * **SEAT_BASED** subscription to use a linked recurring credit with an allocation per - * seat. `seat_config` must be provided with this option. - */ - class QuantityManagementMode + "BillingCycleConfig{anchorDate=$anchorDate, invoicePlacement=$invoicePlacement, additionalProperties=$additionalProperties}" + } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields @JsonCreator - private constructor(private val value: JsonField) : Enum { + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) companion object { - @JvmField val SEAT_BASED = of("SEAT_BASED") + /** Returns a mutable builder for constructing an instance of [CustomFields]. */ + @JvmStatic fun builder() = Builder() + } - @JvmField val QUANTITY_ONLY = of("QUANTITY_ONLY") + /** A builder for [CustomFields]. */ + class Builder internal constructor() { - @JvmStatic fun of(value: String) = QuantityManagementMode(JsonField.of(value)) - } + private var additionalProperties: MutableMap = mutableMapOf() - /** An enum containing [QuantityManagementMode]'s known values. */ - enum class Known { - SEAT_BASED, - QUANTITY_ONLY, - } + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } - /** - * An enum containing [QuantityManagementMode]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [QuantityManagementMode] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEAT_BASED, - QUANTITY_ONLY, - /** - * An enum member indicating that [QuantityManagementMode] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEAT_BASED -> Value.SEAT_BASED - QUANTITY_ONLY -> Value.QUANTITY_ONLY - else -> Value._UNKNOWN + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SEAT_BASED -> Known.SEAT_BASED - QUANTITY_ONLY -> Known.QUANTITY_ONLY - else -> - throw MetronomeInvalidDataException( - "Unknown QuantityManagementMode: $value" - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + } + private var validated: Boolean = false /** @@ -17541,12 +21082,11 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): QuantityManagementMode = apply { + fun validate(): CustomFields = apply { if (validated) { return@apply } - known() validated = true } @@ -17564,93 +21104,64 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is QuantityManagementMode && value == other.value + return other is CustomFields && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" } - class QuantitySchedule + class SeatConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val quantity: JsonField, - private val startingAt: JsonField, - private val endingBefore: JsonField, + private val seatGroupKey: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + @JsonProperty("seat_group_key") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - ) : this(quantity, startingAt, endingBefore, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun quantity(): Double = quantity.getRequired("quantity") + seatGroupKey: JsonField = JsonMissing.of() + ) : this(seatGroupKey, mutableMapOf()) /** + * The property name, sent on usage events, that identifies the seat ID associated + * with the usage event. For example, the property name might be seat_id or user_id. + * The property must be set as a group key on billable metrics and a + * presentation/pricing group key on contract products. This allows linked recurring + * credits with an allocation per seat to be consumed by only one seat's usage. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [seatGroupKey]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("ending_before") + @JsonProperty("seat_group_key") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _seatGroupKey(): JsonField = seatGroupKey @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17667,70 +21178,48 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [QuantitySchedule]. - * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [QuantitySchedule]. */ - class Builder internal constructor() { - - private var quantity: JsonField? = null - private var startingAt: JsonField? = null - private var endingBefore: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(quantitySchedule: QuantitySchedule) = apply { - quantity = quantitySchedule.quantity - startingAt = quantitySchedule.startingAt - endingBefore = quantitySchedule.endingBefore - additionalProperties = quantitySchedule.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) - - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [SeatConfig]. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * The following fields are required: + * ```java + * .seatGroupKey() + * ``` */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SeatConfig]. */ + class Builder internal constructor() { + + private var seatGroupKey: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(seatConfig: SeatConfig) = apply { + seatGroupKey = seatConfig.seatGroupKey + additionalProperties = seatConfig.additionalProperties.toMutableMap() } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** + * The property name, sent on usage events, that identifies the seat ID + * associated with the usage event. For example, the property name might be + * seat_id or user_id. The property must be set as a group key on billable + * metrics and a presentation/pricing group key on contract products. This + * allows linked recurring credits with an allocation per seat to be consumed by + * only one seat's usage. + */ + fun seatGroupKey(seatGroupKey: String) = + seatGroupKey(JsonField.of(seatGroupKey)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.seatGroupKey] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.seatGroupKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun seatGroupKey(seatGroupKey: JsonField) = apply { + this.seatGroupKey = seatGroupKey } fun additionalProperties(additionalProperties: Map) = apply { @@ -17755,1149 +21244,1457 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - /** - * Returns an immutable instance of [QuantitySchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .quantity() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): QuantitySchedule = - QuantitySchedule( - checkRequired("quantity", quantity), - checkRequired("startingAt", startingAt), - endingBefore, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns an immutable instance of [SeatConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .seatGroupKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SeatConfig = + SeatConfig( + checkRequired("seatGroupKey", seatGroupKey), + 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 MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): SeatConfig = apply { + if (validated) { + return@apply + } + + seatGroupKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (seatGroupKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SeatConfig && + seatGroupKey == other.seatGroupKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(seatGroupKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SeatConfig{seatGroupKey=$seatGroupKey, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddSubscription && + billingPeriods == other.billingPeriods && + collectionSchedule == other.collectionSchedule && + proration == other.proration && + quantityManagementMode == other.quantityManagementMode && + quantitySchedule == other.quantitySchedule && + startingAt == other.startingAt && + subscriptionRate == other.subscriptionRate && + id == other.id && + billingCycleConfig == other.billingCycleConfig && + customFields == other.customFields && + description == other.description && + endingBefore == other.endingBefore && + fiatCreditTypeId == other.fiatCreditTypeId && + name == other.name && + seatConfig == other.seatConfig && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + billingPeriods, + collectionSchedule, + proration, + quantityManagementMode, + quantitySchedule, + startingAt, + subscriptionRate, + id, + billingCycleConfig, + customFields, + description, + endingBefore, + fiatCreditTypeId, + name, + seatConfig, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddSubscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, billingCycleConfig=$billingCycleConfig, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" + } + + class AddUsageFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupKey: JsonField, + private val groupValues: JsonField>, + private val startingAt: JsonField, + private val endingBefore: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("group_key") + @ExcludeMissing + groupKey: JsonField = JsonMissing.of(), + @JsonProperty("group_values") + @ExcludeMissing + groupValues: JsonField> = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + ) : this(groupKey, groupValues, startingAt, endingBefore, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupKey(): String = groupKey.getRequired("group_key") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupValues(): List = groupValues.getRequired("group_values") + + /** + * This will match contract starting_at value if usage filter is active from the + * beginning of the contract. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + + /** + * This will match contract ending_before value if usage filter is active until the end + * of the contract. It will be undefined if the contract is open-ended. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + + /** + * Returns the raw JSON value of [groupKey]. + * + * Unlike [groupKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group_key") @ExcludeMissing fun _groupKey(): JsonField = groupKey + + /** + * Returns the raw JSON value of [groupValues]. + * + * Unlike [groupValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group_values") + @ExcludeMissing + fun _groupValues(): JsonField> = groupValues + + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt + + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): QuantitySchedule = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - quantity() - startingAt() - endingBefore() - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of [AddUsageFilter]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .groupKey() + * .groupValues() + * .startingAt() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + @JvmStatic fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [AddUsageFilter]. */ + class Builder internal constructor() { - return other is QuantitySchedule && - quantity == other.quantity && - startingAt == other.startingAt && - endingBefore == other.endingBefore && - additionalProperties == other.additionalProperties - } + private var groupKey: JsonField? = null + private var groupValues: JsonField>? = null + private var startingAt: JsonField? = null + private var endingBefore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private val hashCode: Int by lazy { - Objects.hash(quantity, startingAt, endingBefore, additionalProperties) + @JvmSynthetic + internal fun from(addUsageFilter: AddUsageFilter) = apply { + groupKey = addUsageFilter.groupKey + groupValues = addUsageFilter.groupValues.map { it.toMutableList() } + startingAt = addUsageFilter.startingAt + endingBefore = addUsageFilter.endingBefore + additionalProperties = addUsageFilter.additionalProperties.toMutableMap() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "QuantitySchedule{quantity=$quantity, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" - } - - class SubscriptionRate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val billingFrequency: JsonField, - private val product: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("billing_frequency") - @ExcludeMissing - billingFrequency: JsonField = JsonMissing.of(), - @JsonProperty("product") - @ExcludeMissing - product: JsonField = JsonMissing.of(), - ) : this(billingFrequency, product, mutableMapOf()) + fun groupKey(groupKey: String) = groupKey(JsonField.of(groupKey)) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * Sets [Builder.groupKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun billingFrequency(): BillingFrequency = - billingFrequency.getRequired("billing_frequency") + fun groupKey(groupKey: JsonField) = apply { this.groupKey = groupKey } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun product(): Product = product.getRequired("product") + fun groupValues(groupValues: List) = groupValues(JsonField.of(groupValues)) /** - * Returns the raw JSON value of [billingFrequency]. + * Sets [Builder.groupValues] to an arbitrary JSON value. * - * Unlike [billingFrequency], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.groupValues] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - @JsonProperty("billing_frequency") - @ExcludeMissing - fun _billingFrequency(): JsonField = billingFrequency + fun groupValues(groupValues: JsonField>) = apply { + this.groupValues = groupValues.map { it.toMutableList() } + } /** - * Returns the raw JSON value of [product]. + * Adds a single [String] to [groupValues]. * - * Unlike [product], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - @JsonProperty("product") - @ExcludeMissing - fun _product(): JsonField = product - - @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 [SubscriptionRate]. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun addGroupValue(groupValue: String) = apply { + groupValues = + (groupValues ?: JsonField.of(mutableListOf())).also { + checkKnown("groupValues", it).add(groupValue) + } } - /** A builder for [SubscriptionRate]. */ - class Builder internal constructor() { - - private var billingFrequency: JsonField? = null - private var product: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionRate: SubscriptionRate) = apply { - billingFrequency = subscriptionRate.billingFrequency - product = subscriptionRate.product - additionalProperties = subscriptionRate.additionalProperties.toMutableMap() - } - - fun billingFrequency(billingFrequency: BillingFrequency) = - billingFrequency(JsonField.of(billingFrequency)) - - /** - * Sets [Builder.billingFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.billingFrequency] with a well-typed - * [BillingFrequency] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingFrequency(billingFrequency: JsonField) = apply { - this.billingFrequency = billingFrequency - } - - fun product(product: Product) = product(JsonField.of(product)) + /** + * This will match contract starting_at value if usage filter is active from the + * beginning of the contract. + */ + fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) - /** - * Sets [Builder.product] to an arbitrary JSON value. - * - * You should usually call [Builder.product] with a well-typed [Product] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun product(product: JsonField) = apply { this.product = product } + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * This will match contract ending_before value if usage filter is active until the + * end of the contract. It will be undefined if the contract is open-ended. + */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an immutable instance of [SubscriptionRate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .billingFrequency() - * .product() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionRate = - SubscriptionRate( - checkRequired("billingFrequency", billingFrequency), - checkRequired("product", product), - additionalProperties.toMutableMap(), - ) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Validates that the types of all values in this object match their expected types - * recursively. + * Returns an immutable instance of [AddUsageFilter]. * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * The following fields are required: + * ```java + * .groupKey() + * .groupValues() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun validate(): SubscriptionRate = apply { - if (validated) { - return@apply - } + fun build(): AddUsageFilter = + AddUsageFilter( + checkRequired("groupKey", groupKey), + checkRequired("groupValues", groupValues).map { it.toImmutable() }, + checkRequired("startingAt", startingAt), + endingBefore, + additionalProperties.toMutableMap(), + ) + } - billingFrequency().validate() - product().validate() - validated = true - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AddUsageFilter = apply { + if (validated) { + return@apply + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (billingFrequency.asKnown().getOrNull()?.validity() ?: 0) + - (product.asKnown().getOrNull()?.validity() ?: 0) + groupKey() + groupValues() + startingAt() + endingBefore() + validated = true + } - class BillingFrequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupKey.asKnown().isPresent) 1 else 0) + + (groupValues.asKnown().getOrNull()?.size ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val MONTHLY = of("MONTHLY") + return other is AddUsageFilter && + groupKey == other.groupKey && + groupValues == other.groupValues && + startingAt == other.startingAt && + endingBefore == other.endingBefore && + additionalProperties == other.additionalProperties + } - @JvmField val QUARTERLY = of("QUARTERLY") + private val hashCode: Int by lazy { + Objects.hash(groupKey, groupValues, startingAt, endingBefore, additionalProperties) + } - @JvmField val ANNUAL = of("ANNUAL") + override fun hashCode(): Int = hashCode - @JvmField val WEEKLY = of("WEEKLY") + override fun toString() = + "AddUsageFilter{groupKey=$groupKey, groupValues=$groupValues, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = BillingFrequency(JsonField.of(value)) - } + class ArchiveCommit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [BillingFrequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** - * An enum containing [BillingFrequency]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [BillingFrequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MONTHLY, - QUARTERLY, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [BillingFrequency] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException( - "Unknown BillingFrequency: $value" - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): BillingFrequency = apply { - if (validated) { - return@apply - } + companion object { - known() - validated = true - } + /** + * Returns a mutable builder for constructing an instance of [ArchiveCommit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** A builder for [ArchiveCommit]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun from(archiveCommit: ArchiveCommit) = apply { + id = archiveCommit.id + additionalProperties = archiveCommit.additionalProperties.toMutableMap() + } - return other is BillingFrequency && value == other.value - } + fun id(id: String) = id(JsonField.of(id)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - class Product - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun name(): String = name.getRequired("name") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns an immutable instance of [ArchiveCommit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArchiveCommit = + ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + private var validated: Boolean = false - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ArchiveCommit = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + id() + validated = true + } - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - companion object { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - /** - * Returns a mutable builder for constructing an instance of [Product]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [Product]. */ - class Builder internal constructor() { + return other is ArchiveCommit && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + override fun hashCode(): Int = hashCode - @JvmSynthetic - internal fun from(product: Product) = apply { - id = product.id - name = product.name - additionalProperties = product.additionalProperties.toMutableMap() - } + override fun toString() = + "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" + } - fun id(id: String) = id(JsonField.of(id)) + class ArchiveCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - fun name(name: String) = name(JsonField.of(name)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun toBuilder() = Builder().from(this) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + companion object { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a mutable builder for constructing an instance of [ArchiveCredit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns an immutable instance of [Product]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Product = - Product( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } + /** A builder for [ArchiveCredit]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Product = apply { - if (validated) { - return@apply - } + @JvmSynthetic + internal fun from(archiveCredit: ArchiveCredit) = apply { + id = archiveCredit.id + additionalProperties = archiveCredit.additionalProperties.toMutableMap() + } - id() - name() - validated = true - } + fun id(id: String) = id(JsonField.of(id)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is Product && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(id, name, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Product{id=$id, name=$name, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [ArchiveCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ArchiveCredit = + ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ArchiveCredit = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + id() + validated = true + } - return other is SubscriptionRate && - billingFrequency == other.billingFrequency && - product == other.product && - additionalProperties == other.additionalProperties + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - private val hashCode: Int by lazy { - Objects.hash(billingFrequency, product, additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionRate{billingFrequency=$billingFrequency, product=$product, additionalProperties=$additionalProperties}" + return other is ArchiveCredit && + id == other.id && + additionalProperties == other.additionalProperties } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + override fun hashCode(): Int = hashCode - fun toBuilder() = Builder().from(this) + override fun toString() = + "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" + } - companion object { + class ArchiveScheduledCharge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of + * [ArchiveScheduledCharge]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [ArchiveScheduledCharge]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [CustomFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { + id = archiveScheduledCharge.id + additionalProperties = + archiveScheduledCharge.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun id(id: String) = id(JsonField.of(id)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): CustomFields = apply { - if (validated) { - return@apply - } + fun id(id: JsonField) = apply { this.id = id } - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [ArchiveScheduledCharge]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + fun build(): ArchiveScheduledCharge = + ArchiveScheduledCharge( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is CustomFields && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ArchiveScheduledCharge = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + id() + validated = true } - class SeatConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val seatGroupKey: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("seat_group_key") - @ExcludeMissing - seatGroupKey: JsonField = JsonMissing.of() - ) : this(seatGroupKey, mutableMapOf()) - - /** - * The property name, sent on usage events, that identifies the seat ID associated - * with the usage event. For example, the property name might be seat_id or user_id. - * The property must be set as a group key on billable metrics and a - * presentation/pricing group key on contract products. This allows linked recurring - * credits with an allocation per seat to be consumed by only one seat's usage. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun seatGroupKey(): String = seatGroupKey.getRequired("seat_group_key") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [seatGroupKey]. - * - * Unlike [seatGroupKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("seat_group_key") - @ExcludeMissing - fun _seatGroupKey(): JsonField = seatGroupKey + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is ArchiveScheduledCharge && + id == other.id && + additionalProperties == other.additionalProperties + } - fun toBuilder() = Builder().from(this) + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - /** - * Returns a mutable builder for constructing an instance of [SeatConfig]. - * - * The following fields are required: - * ```java - * .seatGroupKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun toString() = + "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" + } - /** A builder for [SeatConfig]. */ - class Builder internal constructor() { + class RemoveOverride + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - private var seatGroupKey: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - @JvmSynthetic - internal fun from(seatConfig: SeatConfig) = apply { - seatGroupKey = seatConfig.seatGroupKey - additionalProperties = seatConfig.additionalProperties.toMutableMap() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - /** - * The property name, sent on usage events, that identifies the seat ID - * associated with the usage event. For example, the property name might be - * seat_id or user_id. The property must be set as a group key on billable - * metrics and a presentation/pricing group key on contract products. This - * allows linked recurring credits with an allocation per seat to be consumed by - * only one seat's usage. - */ - fun seatGroupKey(seatGroupKey: String) = - seatGroupKey(JsonField.of(seatGroupKey)) + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Sets [Builder.seatGroupKey] to an arbitrary JSON value. - * - * You should usually call [Builder.seatGroupKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun seatGroupKey(seatGroupKey: JsonField) = apply { - this.seatGroupKey = seatGroupKey - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns a mutable builder for constructing an instance of [RemoveOverride]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [RemoveOverride]. */ + class Builder internal constructor() { - /** - * Returns an immutable instance of [SeatConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .seatGroupKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SeatConfig = - SeatConfig( - checkRequired("seatGroupKey", seatGroupKey), - additionalProperties.toMutableMap(), - ) + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeOverride: RemoveOverride) = apply { + id = removeOverride.id + additionalProperties = removeOverride.additionalProperties.toMutableMap() } - private var validated: Boolean = false + fun id(id: String) = id(JsonField.of(id)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun validate(): SeatConfig = apply { - if (validated) { - return@apply - } + fun id(id: JsonField) = apply { this.id = id } - seatGroupKey() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [RemoveOverride]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = (if (seatGroupKey.asKnown().isPresent) 1 else 0) + fun build(): RemoveOverride = + RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is SeatConfig && - seatGroupKey == other.seatGroupKey && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): RemoveOverride = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(seatGroupKey, additionalProperties) - } + id() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "SeatConfig{seatGroupKey=$seatGroupKey, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddSubscription && - billingPeriods == other.billingPeriods && - collectionSchedule == other.collectionSchedule && - proration == other.proration && - quantityManagementMode == other.quantityManagementMode && - quantitySchedule == other.quantitySchedule && - startingAt == other.startingAt && - subscriptionRate == other.subscriptionRate && + return other is RemoveOverride && id == other.id && - customFields == other.customFields && - description == other.description && - endingBefore == other.endingBefore && - fiatCreditTypeId == other.fiatCreditTypeId && - name == other.name && - seatConfig == other.seatConfig && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - billingPeriods, - collectionSchedule, - proration, - quantityManagementMode, - quantitySchedule, - startingAt, - subscriptionRate, - id, - customFields, - description, - endingBefore, - fiatCreditTypeId, - name, - seatConfig, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddSubscription{billingPeriods=$billingPeriods, collectionSchedule=$collectionSchedule, proration=$proration, quantityManagementMode=$quantityManagementMode, quantitySchedule=$quantitySchedule, startingAt=$startingAt, subscriptionRate=$subscriptionRate, id=$id, customFields=$customFields, description=$description, endingBefore=$endingBefore, fiatCreditTypeId=$fiatCreditTypeId, name=$name, seatConfig=$seatConfig, additionalProperties=$additionalProperties}" + "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" } - class AddUsageFilter + class UpdateCommit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupKey: JsonField, - private val groupValues: JsonField>, - private val startingAt: JsonField, - private val endingBefore: JsonField, + private val id: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val invoiceSchedule: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("group_key") + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") @ExcludeMissing - groupKey: JsonField = JsonMissing.of(), - @JsonProperty("group_values") + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") @ExcludeMissing - groupValues: JsonField> = JsonMissing.of(), - @JsonProperty("starting_at") + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - ) : this(groupKey, groupValues, startingAt, endingBefore, mutableMapOf()) + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("invoice_schedule") + @ExcludeMissing + invoiceSchedule: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") + + /** + * Which products the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") + + /** + * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Optional configuration for commit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun invoiceSchedule(): Optional = + invoiceSchedule.getOptional("invoice_schedule") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + + /** + * If multiple commits are applicable, the one with the lower priority will apply first. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") + + /** + * If set, the commit's rate type was updated to the specified value. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") + + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to + * target usage by product or product tag, pass those values in the body of + * `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule + + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds + + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun groupKey(): String = groupKey.getRequired("group_key") + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun groupValues(): List = groupValues.getRequired("group_values") + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration /** - * This will match contract starting_at value if usage filter is active from the - * beginning of the contract. + * Returns the raw JSON value of [invoiceSchedule]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + @JsonProperty("invoice_schedule") + @ExcludeMissing + fun _invoiceSchedule(): JsonField = invoiceSchedule /** - * This will match contract ending_before value if usage filter is active until the end - * of the contract. It will be undefined if the contract is open-ended. + * Returns the raw JSON value of [name]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [groupKey]. + * Returns the raw JSON value of [netsuiteSalesOrderId]. * - * Unlike [groupKey], this method doesn't throw if the JSON field has an unexpected + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("group_key") @ExcludeMissing fun _groupKey(): JsonField = groupKey + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority /** - * Returns the raw JSON value of [groupValues]. + * Returns the raw JSON value of [productId]. * - * Unlike [groupValues], this method doesn't throw if the JSON field has an unexpected + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("group_values") + @JsonProperty("product_id") @ExcludeMissing - fun _groupValues(): JsonField> = groupValues + fun _productId(): JsonField = productId /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [rateType]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an unexpected + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("starting_at") + @JsonProperty("rate_type") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _rateType(): JsonField = rateType /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [rolloverFraction]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction + + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("ending_before") + @JsonProperty("specifiers") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _specifiers(): JsonField> = specifiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -18914,294 +22711,346 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AddUsageFilter]. + * Returns a mutable builder for constructing an instance of [UpdateCommit]. * * The following fields are required: * ```java - * .groupKey() - * .groupValues() - * .startingAt() + * .id() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddUsageFilter]. */ + /** A builder for [UpdateCommit]. */ class Builder internal constructor() { - private var groupKey: JsonField? = null - private var groupValues: JsonField>? = null - private var startingAt: JsonField? = null - private var endingBefore: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var invoiceSchedule: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addUsageFilter: AddUsageFilter) = apply { - groupKey = addUsageFilter.groupKey - groupValues = addUsageFilter.groupValues.map { it.toMutableList() } - startingAt = addUsageFilter.startingAt - endingBefore = addUsageFilter.endingBefore - additionalProperties = addUsageFilter.additionalProperties.toMutableMap() + internal fun from(updateCommit: UpdateCommit) = apply { + id = updateCommit.id + accessSchedule = updateCommit.accessSchedule + applicableProductIds = + updateCommit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCommit.applicableProductTags.map { it.toMutableList() } + description = updateCommit.description + hierarchyConfiguration = updateCommit.hierarchyConfiguration + invoiceSchedule = updateCommit.invoiceSchedule + name = updateCommit.name + netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId + priority = updateCommit.priority + productId = updateCommit.productId + rateType = updateCommit.rateType + rolloverFraction = updateCommit.rolloverFraction + specifiers = updateCommit.specifiers.map { it.toMutableList() } + additionalProperties = updateCommit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) + + /** + * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.accessSchedule] with a well-typed + * [AccessSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule + } + + /** + * Which products the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) + + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) + + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } + + /** + * Which tags the commit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the commit applies to all + * products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) + + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) + + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description } - fun groupKey(groupKey: String) = groupKey(JsonField.of(groupKey)) + /** Optional configuration for commit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) /** - * Sets [Builder.groupKey] to an arbitrary JSON value. + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. * - * You should usually call [Builder.groupKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun groupKey(groupKey: JsonField) = apply { this.groupKey = groupKey } + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - fun groupValues(groupValues: List) = groupValues(JsonField.of(groupValues)) + fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = + invoiceSchedule(JsonField.of(invoiceSchedule)) /** - * Sets [Builder.groupValues] to an arbitrary JSON value. + * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. * - * You should usually call [Builder.groupValues] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.invoiceSchedule] with a well-typed + * [InvoiceSchedule] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun groupValues(groupValues: JsonField>) = apply { - this.groupValues = groupValues.map { it.toMutableList() } + fun invoiceSchedule(invoiceSchedule: JsonField) = apply { + this.invoiceSchedule = invoiceSchedule } + fun name(name: String) = name(JsonField.of(name)) + /** - * Adds a single [String] to [groupValues]. + * Sets [Builder.name] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addGroupValue(groupValue: String) = apply { - groupValues = - (groupValues ?: JsonField.of(mutableListOf())).also { - checkKnown("groupValues", it).add(groupValue) - } - } + fun name(name: JsonField) = apply { this.name = name } + + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) /** - * This will match contract starting_at value if usage filter is active from the - * beginning of the contract. + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. */ - fun startingAt(startingAt: OffsetDateTime) = startingAt(JsonField.of(startingAt)) + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed [OffsetDateTime] + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId } /** - * This will match contract ending_before value if usage filter is active until the - * end of the contract. It will be undefined if the contract is open-ended. + * If multiple commits are applicable, the one with the lower priority will apply + * first. */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Alias for [Builder.priority]. * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun priority(priority: Double) = priority(priority as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) /** - * Returns an immutable instance of [AddUsageFilter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupKey() - * .groupValues() - * .startingAt() - * ``` + * Sets [Builder.priority] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun build(): AddUsageFilter = - AddUsageFilter( - checkRequired("groupKey", groupKey), - checkRequired("groupValues", groupValues).map { it.toImmutable() }, - checkRequired("startingAt", startingAt), - endingBefore, - 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 MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): AddUsageFilter = apply { - if (validated) { - return@apply - } - - groupKey() - groupValues() - startingAt() - endingBefore() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupKey.asKnown().isPresent) 1 else 0) + - (groupValues.asKnown().getOrNull()?.size ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddUsageFilter && - groupKey == other.groupKey && - groupValues == other.groupValues && - startingAt == other.startingAt && - endingBefore == other.endingBefore && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(groupKey, groupValues, startingAt, endingBefore, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddUsageFilter{groupKey=$groupKey, groupValues=$groupValues, startingAt=$startingAt, endingBefore=$endingBefore, additionalProperties=$additionalProperties}" - } - - class ArchiveCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun priority(priority: JsonField) = apply { this.priority = priority } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + fun productId(productId: String) = productId(JsonField.of(productId)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** If set, the commit's rate type was updated to the specified value. */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) - companion object { + /** + * Alias for calling [Builder.rolloverFraction] with + * `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) /** - * Returns a mutable builder for constructing an instance of [ArchiveCommit]. + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. * - * The following fields are required: - * ```java - * .id() - * ``` + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - @JvmStatic fun builder() = Builder() - } + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } - /** A builder for [ArchiveCommit]. */ - class Builder internal constructor() { + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - @JvmSynthetic - internal fun from(archiveCommit: ArchiveCommit) = apply { - id = archiveCommit.id - additionalProperties = archiveCommit.additionalProperties.toMutableMap() + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } } - fun id(id: String) = id(JsonField.of(id)) - /** - * Sets [Builder.id] to an arbitrary JSON value. + * Adds a single [CommitSpecifierInput] to [specifiers]. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun id(id: JsonField) = apply { this.id = id } + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -19226,7 +23075,7 @@ private constructor( } /** - * Returns an immutable instance of [ArchiveCommit]. + * Returns an immutable instance of [UpdateCommit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -19237,8 +23086,24 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ArchiveCommit = - ArchiveCommit(checkRequired("id", id), additionalProperties.toMutableMap()) + fun build(): UpdateCommit = + UpdateCommit( + checkRequired("id", id), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -19253,12 +23118,25 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): ArchiveCommit = apply { + fun validate(): UpdateCommit = apply { if (validated) { return@apply } id() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + invoiceSchedule().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } validated = true } @@ -19276,1657 +23154,1907 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + class AccessSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") + + /** + * Returns the raw JSON value of [addScheduleItems]. + * + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems + + /** + * Returns the raw JSON value of [removeScheduleItems]. + * + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = + removeScheduleItems + + /** + * Returns the raw JSON value of [updateScheduleItems]. + * + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = + updateScheduleItems + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is ArchiveCommit && - id == other.id && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccessSchedule]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessSchedule]. */ + class Builder internal constructor() { + + private var addScheduleItems: JsonField>? = null + private var removeScheduleItems: JsonField>? = + null + private var updateScheduleItems: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessSchedule: AccessSchedule) = apply { + addScheduleItems = + accessSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + accessSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + accessSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = accessSchedule.additionalProperties.toMutableMap() + } + + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) + + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = + apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } - override fun toString() = - "ArchiveCommit{id=$id, additionalProperties=$additionalProperties}" - } + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } - class ArchiveCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems( + removeScheduleItems: JsonField> + ) = apply { + this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems( + updateScheduleItems: JsonField> + ) = apply { + this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of [ArchiveCredit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [ArchiveCredit]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(archiveCredit: ArchiveCredit) = apply { - id = archiveCredit.id - additionalProperties = archiveCredit.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [AccessSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessSchedule = + AccessSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun id(id: String) = id(JsonField.of(id)) + private var validated: Boolean = false /** - * Sets [Builder.id] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun id(id: JsonField) = apply { this.id = id } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): AccessSchedule = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [ArchiveCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): ArchiveCredit = - ArchiveCredit(checkRequired("id", id), additionalProperties.toMutableMap()) - } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - private var validated: Boolean = false + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): ArchiveCredit = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if 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") - id() - validated = true - } + /** + * RFC 3339 timestamp (exclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * RFC 3339 timestamp (inclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - return other is ArchiveCredit && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "ArchiveCredit{id=$id, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - class ArchiveScheduledCharge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + /** + * Returns a mutable builder for constructing an instance of + * [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + amount = addScheduleItem.amount + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt + additionalProperties = + addScheduleItem.additionalProperties.toMutableMap() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun toBuilder() = Builder().from(this) + /** + * 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 } - companion object { + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - /** - * Returns a mutable builder for constructing an instance of - * [ArchiveScheduledCharge]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** A builder for [ArchiveScheduledCharge]. */ - class Builder internal constructor() { + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - @JvmSynthetic - internal fun from(archiveScheduledCharge: ArchiveScheduledCharge) = apply { - id = archiveScheduledCharge.id - additionalProperties = - archiveScheduledCharge.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .endingBefore() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), + additionalProperties.toMutableMap(), + ) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [ArchiveScheduledCharge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ArchiveScheduledCharge = - ArchiveScheduledCharge( - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } + amount() + endingBefore() + startingAt() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): ArchiveScheduledCharge = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - id() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + return other is AddScheduleItem && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + private val hashCode: Int by lazy { + Objects.hash(amount, endingBefore, startingAt, additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode(): Int = hashCode - return other is ArchiveScheduledCharge && - id == other.id && - additionalProperties == other.additionalProperties - } + override fun toString() = + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - override fun toString() = - "ArchiveScheduledCharge{id=$id, additionalProperties=$additionalProperties}" - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") - class RemoveOverride - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun toBuilder() = Builder().from(this) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { - companion object { + private var id: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns a mutable builder for constructing an instance of [RemoveOverride]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() + } - /** A builder for [RemoveOverride]. */ - class Builder internal constructor() { + fun id(id: String) = id(JsonField.of(id)) - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - @JvmSynthetic - internal fun from(removeOverride: RemoveOverride) = apply { - id = removeOverride.id - additionalProperties = removeOverride.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun id(id: String) = id(JsonField.of(id)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var validated: Boolean = false - /** - * Returns an immutable instance of [RemoveOverride]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveOverride = - RemoveOverride(checkRequired("id", id), additionalProperties.toMutableMap()) - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + id() + validated = true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): RemoveOverride = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - id() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - return other is RemoveOverride && - id == other.id && - additionalProperties == other.additionalProperties - } + override fun hashCode(): Int = hashCode - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" + } - override fun hashCode(): Int = hashCode + class UpdateScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "RemoveOverride{id=$id, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - class UpdateCommit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, - private val invoiceSchedule: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("invoice_schedule") - @ExcludeMissing - invoiceSchedule: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - mutableMapOf(), - ) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + /** + * RFC 3339 timestamp (exclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") + /** + * RFC 3339 timestamp (inclusive) + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun startingAt(): Optional = + startingAt.getOptional("starting_at") - /** - * Which products the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Which tags the commit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + /** + * 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 - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** - * Optional configuration for commit hierarchy access control - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun invoiceSchedule(): Optional = - invoiceSchedule.getOptional("invoice_schedule") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + fun toBuilder() = Builder().from(this) - /** - * If multiple commits are applicable, the one with the lower priority will apply first. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + /** + * Returns a mutable builder for constructing an instance of + * [UpdateScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * If set, the commit's rate type was updated to the specified value. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + /** A builder for [UpdateScheduleItem]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to - * target usage by product or product tag, pass those values in the body of - * `specifiers`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + @JvmSynthetic + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt + additionalProperties = + updateScheduleItem.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + /** + * 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 } + + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) + + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Returns the raw JSON value of [invoiceSchedule]. - * - * Unlike [invoiceSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_schedule") - @ExcludeMissing - fun _invoiceSchedule(): JsonField = invoiceSchedule + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + /** + * Returns an immutable instance of [UpdateScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + endingBefore, + startingAt, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + private var validated: Boolean = false - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): UpdateScheduleItem = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + id() + amount() + endingBefore() + startingAt() + validated = true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun toBuilder() = Builder().from(this) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a mutable builder for constructing an instance of [UpdateCommit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + return other is UpdateScheduleItem && + id == other.id && + amount == other.amount && + endingBefore == other.endingBefore && + startingAt == other.startingAt && + additionalProperties == other.additionalProperties + } - /** A builder for [UpdateCommit]. */ - class Builder internal constructor() { + private val hashCode: Int by lazy { + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) + } - private var id: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var invoiceSchedule: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun hashCode(): Int = hashCode - @JvmSynthetic - internal fun from(updateCommit: UpdateCommit) = apply { - id = updateCommit.id - accessSchedule = updateCommit.accessSchedule - applicableProductIds = - updateCommit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCommit.applicableProductTags.map { it.toMutableList() } - description = updateCommit.description - hierarchyConfiguration = updateCommit.hierarchyConfiguration - invoiceSchedule = updateCommit.invoiceSchedule - name = updateCommit.name - netsuiteSalesOrderId = updateCommit.netsuiteSalesOrderId - priority = updateCommit.priority - productId = updateCommit.productId - rateType = updateCommit.rateType - rolloverFraction = updateCommit.rolloverFraction - specifiers = updateCommit.specifiers.map { it.toMutableList() } - additionalProperties = updateCommit.additionalProperties.toMutableMap() + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties } - fun id(id: String) = id(JsonField.of(id)) + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun hashCode(): Int = hashCode - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + override fun toString() = + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } + + class InvoiceSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addScheduleItems: JsonField>, + private val removeScheduleItems: JsonField>, + private val updateScheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_schedule_items") + @ExcludeMissing + addScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("remove_schedule_items") + @ExcludeMissing + removeScheduleItems: JsonField> = JsonMissing.of(), + @JsonProperty("update_schedule_items") + @ExcludeMissing + updateScheduleItems: JsonField> = JsonMissing.of(), + ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. - * - * You should usually call [Builder.accessSchedule] with a well-typed - * [AccessSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule - } + fun addScheduleItems(): Optional> = + addScheduleItems.getOptional("add_schedule_items") /** - * Which products the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + fun removeScheduleItems(): Optional> = + removeScheduleItems.getOptional("remove_schedule_items") /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + fun updateScheduleItems(): Optional> = + updateScheduleItems.getOptional("update_schedule_items") /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * Returns the raw JSON value of [addScheduleItems]. * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + @JsonProperty("add_schedule_items") + @ExcludeMissing + fun _addScheduleItems(): JsonField> = addScheduleItems /** - * Adds a single [String] to [applicableProductIds]. + * Returns the raw JSON value of [removeScheduleItems]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + @JsonProperty("remove_schedule_items") + @ExcludeMissing + fun _removeScheduleItems(): JsonField> = + removeScheduleItems /** - * Which tags the commit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the commit applies to all - * products. + * Returns the raw JSON value of [updateScheduleItems]. + * + * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + @JsonProperty("update_schedule_items") + @ExcludeMissing + fun _updateScheduleItems(): JsonField> = + updateScheduleItems - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvoiceSchedule]. + */ + @JvmStatic fun builder() = Builder() } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + /** A builder for [InvoiceSchedule]. */ + class Builder internal constructor() { + + private var addScheduleItems: JsonField>? = null + private var removeScheduleItems: JsonField>? = + null + private var updateScheduleItems: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceSchedule: InvoiceSchedule) = apply { + addScheduleItems = + invoiceSchedule.addScheduleItems.map { it.toMutableList() } + removeScheduleItems = + invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + updateScheduleItems = + invoiceSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = invoiceSchedule.additionalProperties.toMutableMap() + } + + fun addScheduleItems(addScheduleItems: List) = + addScheduleItems(JsonField.of(addScheduleItems)) + + /** + * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.addScheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addScheduleItems(addScheduleItems: JsonField>) = + apply { + this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [AddScheduleItem] to [addScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { + addScheduleItems = + (addScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("addScheduleItems", it).add(addScheduleItem) + } + } + + fun removeScheduleItems(removeScheduleItems: List) = + removeScheduleItems(JsonField.of(removeScheduleItems)) + + /** + * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.removeScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeScheduleItems( + removeScheduleItems: JsonField> + ) = apply { + this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { + removeScheduleItems = + (removeScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("removeScheduleItems", it).add(removeScheduleItem) + } + } + + fun updateScheduleItems(updateScheduleItems: List) = + updateScheduleItems(JsonField.of(updateScheduleItems)) + + /** + * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.updateScheduleItems] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun updateScheduleItems( + updateScheduleItems: JsonField> + ) = apply { + this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { + updateScheduleItems = + (updateScheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("updateScheduleItems", it).add(updateScheduleItem) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - } - fun description(description: String) = description(JsonField.of(description)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvoiceSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceSchedule = + InvoiceSchedule( + (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - /** Optional configuration for commit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + private var validated: Boolean = false /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - - fun invoiceSchedule(invoiceSchedule: InvoiceSchedule) = - invoiceSchedule(JsonField.of(invoiceSchedule)) - - /** - * Sets [Builder.invoiceSchedule] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * You should usually call [Builder.invoiceSchedule] with a well-typed - * [InvoiceSchedule] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun invoiceSchedule(invoiceSchedule: JsonField) = apply { - this.invoiceSchedule = invoiceSchedule + fun validate(): InvoiceSchedule = apply { + if (validated) { + return@apply + } + + addScheduleItems().ifPresent { it.forEach { it.validate() } } + removeScheduleItems().ifPresent { it.forEach { it.validate() } } + updateScheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - fun name(name: String) = name(JsonField.of(name)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun name(name: JsonField) = apply { this.name = name } + @JvmSynthetic + internal fun validity(): Int = + (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + class AddScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + @JsonCreator + private constructor( + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + /** + * @throws MetronomeInvalidDataException if 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") - /** - * If multiple commits are applicable, the one with the lower priority will apply - * first. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } + /** + * 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 - fun productId(productId: String) = productId(JsonField.of(productId)) + /** + * 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 - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - /** If set, the commit's rate type was updated to the specified value. */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for [Builder.rolloverFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [Builder.rolloverFraction] with - * `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + companion object { - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + /** + * Returns a mutable builder for constructing an instance of + * [AddScheduleItem]. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + /** A builder for [AddScheduleItem]. */ + class Builder internal constructor() { - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + @JvmSynthetic + internal fun from(addScheduleItem: AddScheduleItem) = apply { + timestamp = addScheduleItem.timestamp + amount = addScheduleItem.amount + quantity = addScheduleItem.quantity + unitPrice = addScheduleItem.unitPrice + additionalProperties = + addScheduleItem.additionalProperties.toMutableMap() + } - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) + 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 } - } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * 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 } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - /** - * Returns an immutable instance of [UpdateCommit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateCommit = - UpdateCommit( - checkRequired("id", id), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - hierarchyConfiguration, - invoiceSchedule, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): UpdateCommit = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - id() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - invoiceSchedule().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - validated = true - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AddScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .timestamp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AddScheduleItem = + AddScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (invoiceSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + private var validated: Boolean = false - class AccessSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AddScheduleItem = apply { + if (validated) { + return@apply + } - @JsonCreator - private constructor( - @JsonProperty("add_schedule_items") - @ExcludeMissing - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") - @ExcludeMissing - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") - @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) + timestamp() + amount() + quantity() + unitPrice() + validated = true + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + return other is AddScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [removeScheduleItems]. - * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = - removeScheduleItems + private val hashCode: Int by lazy { + Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + } - /** - * Returns the raw JSON value of [updateScheduleItems]. - * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("update_schedule_items") - @ExcludeMissing - fun _updateScheduleItems(): JsonField> = - updateScheduleItems + override fun hashCode(): Int = hashCode - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun toString() = + "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + class RemoveScheduleItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { - fun toBuilder() = Builder().from(this) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun id(): String = id.getRequired("id") /** - * Returns a mutable builder for constructing an instance of [AccessSchedule]. + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmStatic fun builder() = Builder() - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** A builder for [AccessSchedule]. */ - class Builder internal constructor() { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var addScheduleItems: JsonField>? = null - private var removeScheduleItems: JsonField>? = - null - private var updateScheduleItems: JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = - accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = accessSchedule.additionalProperties.toMutableMap() + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RemoveScheduleItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + /** A builder for [RemoveScheduleItem]. */ + class Builder internal constructor() { - /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addScheduleItems(addScheduleItems: JsonField>) = - apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + private var id: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { + id = removeScheduleItem.id + additionalProperties = + removeScheduleItem.additionalProperties.toMutableMap() } - /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - } - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun removeScheduleItems( - removeScheduleItems: JsonField> - ) = apply { - this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) - } - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun updateScheduleItems( - updateScheduleItems: JsonField> - ) = apply { - this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } + /** + * Returns an immutable instance of [RemoveScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveScheduleItem = + RemoveScheduleItem( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) } + private var validated: Boolean = false + /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): RemoveScheduleItem = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + id() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AccessSchedule]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AccessSchedule = apply { - if (validated) { - return@apply + return other is RemoveScheduleItem && + id == other.id && + additionalProperties == other.additionalProperties } - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + override fun toString() = + "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" + } - class AddScheduleItem + class UpdateScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val id: JsonField, private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, + private val quantity: JsonField, + private val timestamp: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") + quantity: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") + fun id(): String = id.getRequired("id") /** - * RFC 3339 timestamp (exclusive) - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + fun amount(): Optional = amount.getOptional("amount") /** - * RFC 3339 timestamp (inclusive) - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * type (e.g. if the server responded with an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): Optional = timestamp.getOptional("timestamp") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [amount]. @@ -20939,24 +25067,34 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [endingBefore]. + * Returns the raw JSON value of [quantity]. * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * Unlike [quantity], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("ending_before") + @JsonProperty("quantity") @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [startingAt]. + * Returns the raw JSON value of [timestamp]. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an + * Unlike [timestamp], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("starting_at") + @JsonProperty("timestamp") @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun _timestamp(): JsonField = timestamp + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -20974,36 +25112,49 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [AddScheduleItem]. + * [UpdateScheduleItem]. * * The following fields are required: * ```java - * .amount() - * .endingBefore() - * .startingAt() + * .id() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddScheduleItem]. */ + /** A builder for [UpdateScheduleItem]. */ class Builder internal constructor() { - private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null + private var id: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt + internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { + id = updateScheduleItem.id + amount = updateScheduleItem.amount + quantity = updateScheduleItem.quantity + timestamp = updateScheduleItem.timestamp + unitPrice = updateScheduleItem.unitPrice additionalProperties = - addScheduleItem.additionalProperties.toMutableMap() + updateScheduleItem.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -21015,34 +25166,44 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + fun timestamp(timestamp: OffsetDateTime) = + timestamp(JsonField.of(timestamp)) /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Sets [Builder.timestamp] to an arbitrary JSON value. * - * You should usually call [Builder.startingAt] with a well-typed + * 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 startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = @@ -21055,614 +25216,1096 @@ private constructor( additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateScheduleItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateScheduleItem = + UpdateScheduleItem( + checkRequired("id", id), + amount, + quantity, + timestamp, + unitPrice, + 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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): UpdateScheduleItem = apply { + if (validated) { + return@apply + } + + id() + amount() + quantity() + timestamp() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateScheduleItem && + id == other.id && + amount == other.amount && + quantity == other.quantity && + timestamp == other.timestamp && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + quantity, + timestamp, + unitPrice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSchedule && + addScheduleItems == other.addScheduleItems && + removeScheduleItems == other.removeScheduleItems && + updateScheduleItems == other.updateScheduleItems && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addScheduleItems, + removeScheduleItems, + updateScheduleItems, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + } + + /** If set, the commit's rate type was updated to the specified value. */ + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val COMMIT_RATE = of("COMMIT_RATE") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val LIST_RATE = of("LIST_RATE") - /** - * Returns an immutable instance of [AddScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AddScheduleItem = - AddScheduleItem( - checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) - } + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [RateType]'s known values. */ + enum class Known { + COMMIT_RATE, + LIST_RATE, + } + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT_RATE, + LIST_RATE, /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * An enum member indicating that [RateType] was instantiated with an unknown + * value. */ - fun validate(): AddScheduleItem = apply { - if (validated) { - return@apply - } + _UNKNOWN, + } - amount() - endingBefore() - startingAt() - validated = true + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT_RATE -> Value.COMMIT_RATE + LIST_RATE -> Value.LIST_RATE + else -> Value._UNKNOWN } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + COMMIT_RATE -> Known.COMMIT_RATE + LIST_RATE -> Known.LIST_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is AddScheduleItem && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false } - override fun hashCode(): Int = hashCode + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value } - class RemoveScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateCommit && + id == other.id && + accessSchedule == other.accessSchedule && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + description == other.description && + hierarchyConfiguration == other.hierarchyConfiguration && + invoiceSchedule == other.invoiceSchedule && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + priority == other.priority && + productId == other.productId && + rateType == other.rateType && + rolloverFraction == other.rolloverFraction && + specifiers == other.specifiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + invoiceSchedule, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateCommit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" + } + + class UpdateCredit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val accessSchedule: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val description: JsonField, + private val hierarchyConfiguration: JsonField, + private val name: JsonField, + private val netsuiteSalesOrderId: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val rateType: JsonField, + private val rolloverFraction: JsonField, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_schedule") + @ExcludeMissing + accessSchedule: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + hierarchyConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + netsuiteSalesOrderId: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") + @ExcludeMissing + rateType: JsonField = JsonMissing.of(), + @JsonProperty("rollover_fraction") + @ExcludeMissing + rolloverFraction: JsonField = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + id, + accessSchedule, + applicableProductIds, + applicableProductTags, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + specifiers, + mutableMapOf(), + ) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun accessSchedule(): Optional = + accessSchedule.getOptional("access_schedule") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Which products the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags + * or specifiers are not provided, the credit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - fun toBuilder() = Builder().from(this) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - companion object { + /** + * Optional configuration for credit hierarchy access control + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hierarchyConfiguration(): Optional = + hierarchyConfiguration.getOptional("hierarchy_configuration") - /** - * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - /** A builder for [RemoveScheduleItem]. */ - class Builder internal constructor() { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") - private var id: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * If multiple credits are applicable, the one with the lower priority will apply first. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id - additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - fun id(id: String) = id(JsonField.of(id)) + /** + * If set, the credit's rate type was updated to the specified value. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rateType(): Optional = rateType.getOptional("rate_type") - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rolloverFraction(): Optional = + rolloverFraction.getOptional("rollover_fraction") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to + * target usage by product or product tag, pass those values in the body of + * `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [accessSchedule]. + * + * Unlike [accessSchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_schedule") + @ExcludeMissing + fun _accessSchedule(): JsonField = accessSchedule - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [applicableProductIds]. + * + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags - /** - * Returns an immutable instance of [RemoveScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - private var validated: Boolean = false + /** + * Returns the raw JSON value of [hierarchyConfiguration]. + * + * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("hierarchy_configuration") + @ExcludeMissing + fun _hierarchyConfiguration(): JsonField = + hierarchyConfiguration - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): RemoveScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - id() - validated = true - } + /** + * Returns the raw JSON value of [netsuiteSalesOrderId]. + * + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [rateType]. + * + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rate_type") + @ExcludeMissing + fun _rateType(): JsonField = rateType - return other is RemoveScheduleItem && - id == other.id && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [rolloverFraction]. + * + * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rollover_fraction") + @ExcludeMissing + fun _rolloverFraction(): JsonField = rolloverFraction - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /** + * Returns the raw JSON value of [specifiers]. + * + * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { + fun toBuilder() = Builder().from(this) - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) + companion object { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + /** A builder for [UpdateCredit]. */ + class Builder internal constructor() { - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") + private var id: JsonField? = null + private var accessSchedule: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var hierarchyConfiguration: JsonField = + JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var rolloverFraction: JsonField = JsonMissing.of() + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = - startingAt.getOptional("starting_at") + @JvmSynthetic + internal fun from(updateCredit: UpdateCredit) = apply { + id = updateCredit.id + accessSchedule = updateCredit.accessSchedule + applicableProductIds = + updateCredit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + updateCredit.applicableProductTags.map { it.toMutableList() } + description = updateCredit.description + hierarchyConfiguration = updateCredit.hierarchyConfiguration + name = updateCredit.name + netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId + priority = updateCredit.priority + productId = updateCredit.productId + rateType = updateCredit.rateType + rolloverFraction = updateCredit.rolloverFraction + specifiers = updateCredit.specifiers.map { it.toMutableList() } + additionalProperties = updateCredit.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun id(id: String) = id(JsonField.of(id)) - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun accessSchedule(accessSchedule: AccessSchedule) = + accessSchedule(JsonField.of(accessSchedule)) - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + /** + * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.accessSchedule] with a well-typed + * [AccessSchedule] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun accessSchedule(accessSchedule: JsonField) = apply { + this.accessSchedule = accessSchedule + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Which products the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = apply { + this.applicableProductIds = applicableProductIds.map { it.toMutableList() } + } - companion object { + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - /** - * Returns a mutable builder for constructing an instance of - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Which tags the credit applies to. If applicable_product_ids, + * applicable_product_tags or specifiers are not provided, the credit applies to all + * products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = apply { + this.applicableProductTags = applicableProductTags.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) } + } - fun id(id: String) = id(JsonField.of(id)) + fun description(description: String) = description(JsonField.of(description)) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - fun amount(amount: Double) = amount(JsonField.of(amount)) + /** Optional configuration for credit hierarchy access control */ + fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = + hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) - /** - * 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 } + /** + * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.hierarchyConfiguration] with a well-typed + * [CommitHierarchyConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun hierarchyConfiguration( + hierarchyConfiguration: JsonField + ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = + netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) + + /** + * Alias for calling [Builder.netsuiteSalesOrderId] with + * `netsuiteSalesOrderId.orElse(null)`. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = + netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** + * If multiple credits are applicable, the one with the lower priority will apply + * first. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun productId(productId: String) = productId(JsonField.of(productId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** If set, the credit's rate type was updated to the specified value. */ + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.rateType] to an arbitrary JSON value. + * + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun rolloverFraction(rolloverFraction: Double?) = + rolloverFraction(JsonField.ofNullable(rolloverFraction)) - /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for [Builder.rolloverFraction]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun rolloverFraction(rolloverFraction: Double) = + rolloverFraction(rolloverFraction as Double?) - private var validated: Boolean = false + /** + * Alias for calling [Builder.rolloverFraction] with + * `rolloverFraction.orElse(null)`. + */ + fun rolloverFraction(rolloverFraction: Optional) = + rolloverFraction(rolloverFraction.getOrNull()) - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.rolloverFraction] to an arbitrary JSON value. + * + * You should usually call [Builder.rolloverFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun rolloverFraction(rolloverFraction: JsonField) = apply { + this.rolloverFraction = rolloverFraction + } - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) } + } - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an immutable instance of [UpdateCredit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateCredit = + UpdateCredit( + checkRequired("id", id), + accessSchedule, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + description, + hierarchyConfiguration, + name, + netsuiteSalesOrderId, + priority, + productId, + rateType, + rolloverFraction, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): UpdateCredit = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, - ) - } + id() + accessSchedule().ifPresent { it.validate() } + applicableProductIds() + applicableProductTags() + description() + hierarchyConfiguration().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + priority() + productId() + rateType().ifPresent { it.validate() } + rolloverFraction() + specifiers().ifPresent { it.forEach { it.validate() } } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) + + (if (rolloverFraction.asKnown().isPresent) 1 else 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - class InvoiceSchedule + class AccessSchedule @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val addScheduleItems: JsonField>, @@ -21752,12 +26395,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [InvoiceSchedule]. + * Returns a mutable builder for constructing an instance of [AccessSchedule]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoiceSchedule]. */ + /** A builder for [AccessSchedule]. */ class Builder internal constructor() { private var addScheduleItems: JsonField>? = null @@ -21768,14 +26411,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(invoiceSchedule: InvoiceSchedule) = apply { + internal fun from(accessSchedule: AccessSchedule) = apply { addScheduleItems = - invoiceSchedule.addScheduleItems.map { it.toMutableList() } + accessSchedule.addScheduleItems.map { it.toMutableList() } removeScheduleItems = - invoiceSchedule.removeScheduleItems.map { it.toMutableList() } + accessSchedule.removeScheduleItems.map { it.toMutableList() } updateScheduleItems = - invoiceSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = invoiceSchedule.additionalProperties.toMutableMap() + accessSchedule.updateScheduleItems.map { it.toMutableList() } + additionalProperties = accessSchedule.additionalProperties.toMutableMap() } fun addScheduleItems(addScheduleItems: List) = @@ -21884,12 +26527,12 @@ private constructor( } /** - * Returns an immutable instance of [InvoiceSchedule]. + * Returns an immutable instance of [AccessSchedule]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): InvoiceSchedule = - InvoiceSchedule( + fun build(): AccessSchedule = + AccessSchedule( (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, @@ -21909,7 +26552,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): InvoiceSchedule = apply { + fun validate(): AccessSchedule = apply { if (validated) { return@apply } @@ -21945,63 +26588,49 @@ private constructor( class AddScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val timestamp: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + startingAt: JsonField = JsonMissing.of(), + ) : this(amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if 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") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun amount(): Double = amount.getRequired("amount") /** + * RFC 3339 timestamp (exclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") /** - * Returns the raw JSON value of [timestamp]. + * RFC 3339 timestamp (inclusive) * - * Unlike [timestamp], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). */ - @JsonProperty("timestamp") - @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") /** * Returns the raw JSON value of [amount]. @@ -22014,24 +26643,24 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("quantity") + @JsonProperty("ending_before") @ExcludeMissing - fun _quantity(): JsonField = quantity + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * Unlike [startingAt], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22053,7 +26682,9 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -22062,37 +26693,21 @@ private constructor( /** A builder for [AddScheduleItem]. */ class Builder internal constructor() { - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var endingBefore: JsonField? = null + private var startingAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addScheduleItem: AddScheduleItem) = apply { - timestamp = addScheduleItem.timestamp amount = addScheduleItem.amount - quantity = addScheduleItem.quantity - unitPrice = addScheduleItem.unitPrice + endingBefore = addScheduleItem.endingBefore + startingAt = addScheduleItem.startingAt additionalProperties = addScheduleItem.additionalProperties.toMutableMap() } - 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 - } - fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -22104,30 +26719,34 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = @@ -22159,17 +26778,18 @@ private constructor( * * The following fields are required: * ```java - * .timestamp() + * .amount() + * .endingBefore() + * .startingAt() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AddScheduleItem = AddScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, + checkRequired("amount", amount), + checkRequired("endingBefore", endingBefore), + checkRequired("startingAt", startingAt), additionalProperties.toMutableMap(), ) } @@ -22191,10 +26811,9 @@ private constructor( return@apply } - timestamp() amount() - quantity() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -22214,10 +26833,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -22225,21 +26843,20 @@ private constructor( } return other is AddScheduleItem && - timestamp == other.timestamp && amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + Objects.hash(amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AddScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } class RemoveScheduleItem @@ -22422,9 +27039,8 @@ private constructor( private constructor( private val id: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val timestamp: JsonField, - private val unitPrice: JsonField, + private val endingBefore: JsonField, + private val startingAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -22435,17 +27051,14 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("timestamp") + amount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(id, amount, quantity, timestamp, unitPrice, mutableMapOf()) + startingAt: JsonField = JsonMissing.of(), + ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected @@ -22461,22 +27074,22 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** + * RFC 3339 timestamp (exclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun timestamp(): Optional = timestamp.getOptional("timestamp") + fun endingBefore(): Optional = + endingBefore.getOptional("ending_before") /** + * RFC 3339 timestamp (inclusive) + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun startingAt(): Optional = + startingAt.getOptional("starting_at") /** * Returns the raw JSON value of [id]. @@ -22497,34 +27110,24 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [timestamp]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [timestamp], this method doesn't throw if the JSON field has an + * Unlike [endingBefore], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("timestamp") + @JsonProperty("ending_before") @ExcludeMissing - fun _timestamp(): JsonField = timestamp + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [startingAt]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * Unlike [startingAt], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("starting_at") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _startingAt(): JsonField = startingAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22557,9 +27160,8 @@ private constructor( private var id: JsonField? = null private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var timestamp: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var startingAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22567,9 +27169,8 @@ private constructor( internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { id = updateScheduleItem.id amount = updateScheduleItem.amount - quantity = updateScheduleItem.quantity - timestamp = updateScheduleItem.timestamp - unitPrice = updateScheduleItem.unitPrice + endingBefore = updateScheduleItem.endingBefore + startingAt = updateScheduleItem.startingAt additionalProperties = updateScheduleItem.additionalProperties.toMutableMap() } @@ -22596,44 +27197,34 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } - - fun timestamp(timestamp: OffsetDateTime) = - timestamp(JsonField.of(timestamp)) + /** RFC 3339 timestamp (exclusive) */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.timestamp] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.timestamp] with a well-typed + * You should usually call [Builder.endingBefore] 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 + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** RFC 3339 timestamp (inclusive) */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.startingAt] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt } fun additionalProperties(additionalProperties: Map) = @@ -22674,9 +27265,8 @@ private constructor( UpdateScheduleItem( checkRequired("id", id), amount, - quantity, - timestamp, - unitPrice, + endingBefore, + startingAt, additionalProperties.toMutableMap(), ) } @@ -22700,9 +27290,8 @@ private constructor( id() amount() - quantity() - timestamp() - unitPrice() + endingBefore() + startingAt() validated = true } @@ -22724,9 +27313,8 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -22736,27 +27324,19 @@ private constructor( return other is UpdateScheduleItem && id == other.id && amount == other.amount && - quantity == other.quantity && - timestamp == other.timestamp && - unitPrice == other.unitPrice && + endingBefore == other.endingBefore && + startingAt == other.startingAt && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - id, - amount, - quantity, - timestamp, - unitPrice, - additionalProperties, - ) + Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, quantity=$quantity, timestamp=$timestamp, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -22764,7 +27344,7 @@ private constructor( return true } - return other is InvoiceSchedule && + return other is AccessSchedule && addScheduleItems == other.addScheduleItems && removeScheduleItems == other.removeScheduleItems && updateScheduleItems == other.updateScheduleItems && @@ -22783,10 +27363,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" + "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" } - /** If set, the commit's rate type was updated to the specified value. */ + /** If set, the credit's rate type was updated to the specified value. */ class RateType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22802,17 +27382,17 @@ private constructor( companion object { - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - @JvmField val LIST_RATE = of("LIST_RATE") + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) } /** An enum containing [RateType]'s known values. */ enum class Known { - COMMIT_RATE, LIST_RATE, + COMMIT_RATE, } /** @@ -22825,8 +27405,8 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - COMMIT_RATE, LIST_RATE, + COMMIT_RATE, /** * An enum member indicating that [RateType] was instantiated with an unknown * value. @@ -22843,8 +27423,8 @@ private constructor( */ fun value(): Value = when (this) { - COMMIT_RATE -> Value.COMMIT_RATE LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE else -> Value._UNKNOWN } @@ -22859,8 +27439,8 @@ private constructor( */ fun known(): Known = when (this) { - COMMIT_RATE -> Known.COMMIT_RATE LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE else -> throw MetronomeInvalidDataException("Unknown RateType: $value") } @@ -22933,14 +27513,13 @@ private constructor( return true } - return other is UpdateCommit && + return other is UpdateCredit && id == other.id && accessSchedule == other.accessSchedule && applicableProductIds == other.applicableProductIds && applicableProductTags == other.applicableProductTags && description == other.description && hierarchyConfiguration == other.hierarchyConfiguration && - invoiceSchedule == other.invoiceSchedule && name == other.name && netsuiteSalesOrderId == other.netsuiteSalesOrderId && priority == other.priority && @@ -22959,7 +27538,6 @@ private constructor( applicableProductTags, description, hierarchyConfiguration, - invoiceSchedule, name, netsuiteSalesOrderId, priority, @@ -22974,81 +27552,34 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateCommit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, invoiceSchedule=$invoiceSchedule, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" + "UpdateCredit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" } - class UpdateCredit + class UpdateDiscount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, - private val accessSchedule: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val description: JsonField, - private val hierarchyConfiguration: JsonField, + private val customFields: JsonField, private val name: JsonField, private val netsuiteSalesOrderId: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val rateType: JsonField, - private val rolloverFraction: JsonField, - private val specifiers: JsonField>, + private val schedule: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_schedule") - @ExcludeMissing - accessSchedule: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy_configuration") + @JsonProperty("custom_fields") @ExcludeMissing - hierarchyConfiguration: JsonField = JsonMissing.of(), + customFields: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("netsuite_sales_order_id") @ExcludeMissing netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - @JsonProperty("rollover_fraction") - @ExcludeMissing - rolloverFraction: JsonField = JsonMissing.of(), - @JsonProperty("specifiers") + @JsonProperty("schedule") @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - mutableMapOf(), - ) + schedule: JsonField = JsonMissing.of(), + ) : this(id, customFields, name, netsuiteSalesOrderId, schedule, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is @@ -23058,1263 +27589,1612 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun accessSchedule(): Optional = - accessSchedule.getOptional("access_schedule") + fun customFields(): Optional = customFields.getOptional("custom_fields") /** - * Which products the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netsuiteSalesOrderId(): Optional = + netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + + /** + * Must provide either schedule_items or recurring_schedule. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + fun schedule(): Optional = schedule.getOptional("schedule") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Which tags the credit applies to. If applicable_product_ids, applicable_product_tags - * or specifiers are not provided, the credit applies to all products. + * Returns the raw JSON value of [customFields]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun description(): Optional = description.getOptional("description") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Optional configuration for credit hierarchy access control + * Returns the raw JSON value of [netsuiteSalesOrderId]. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun hierarchyConfiguration(): Optional = - hierarchyConfiguration.getOptional("hierarchy_configuration") + @JsonProperty("netsuite_sales_order_id") + @ExcludeMissing + fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Returns the raw JSON value of [schedule]. + * + * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun name(): Optional = name.getOptional("name") + @JsonProperty("schedule") + @ExcludeMissing + fun _schedule(): JsonField = schedule + + @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 [UpdateDiscount]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateDiscount]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customFields: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var netsuiteSalesOrderId: JsonField = JsonMissing.of() + private var schedule: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateDiscount: UpdateDiscount) = apply { + id = updateDiscount.id + customFields = updateDiscount.customFields + name = updateDiscount.name + netsuiteSalesOrderId = updateDiscount.netsuiteSalesOrderId + schedule = updateDiscount.schedule + additionalProperties = updateDiscount.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + fun customFields(customFields: CustomFields) = + customFields(JsonField.of(customFields)) + + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed [CustomFields] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customFields(customFields: JsonField) = apply { + this.customFields = customFields + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = + netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + + /** + * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * + * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { + this.netsuiteSalesOrderId = netsuiteSalesOrderId + } + + /** Must provide either schedule_items or recurring_schedule. */ + fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + + /** + * Sets [Builder.schedule] to an arbitrary JSON value. + * + * You should usually call [Builder.schedule] with a well-typed [Schedule] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateDiscount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateDiscount = + UpdateDiscount( + checkRequired("id", id), + customFields, + name, + netsuiteSalesOrderId, + schedule, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + fun validate(): UpdateDiscount = apply { + if (validated) { + return@apply + } + + id() + customFields().ifPresent { it.validate() } + name() + netsuiteSalesOrderId() + schedule().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * If multiple credits are applicable, the one with the lower priority will apply first. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Used for best match union deserialization. */ - fun priority(): Optional = priority.getOptional("priority") + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (customFields.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + + (schedule.asKnown().getOrNull()?.validity() ?: 0) + + /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ + class CustomFields + @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 { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + /** Returns a mutable builder for constructing an instance of [CustomFields]. */ + @JvmStatic fun builder() = Builder() + } - /** - * If set, the credit's rate type was updated to the specified value. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") + /** A builder for [CustomFields]. */ + class Builder internal constructor() { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rolloverFraction(): Optional = - rolloverFraction.getOptional("rollover_fraction") + private var additionalProperties: MutableMap = mutableMapOf() - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to - * target usage by product or product tag, pass those values in the body of - * `specifiers`. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") + @JvmSynthetic + internal fun from(customFields: CustomFields) = apply { + additionalProperties = customFields.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [accessSchedule]. - * - * Unlike [accessSchedule], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_schedule") - @ExcludeMissing - fun _accessSchedule(): JsonField = accessSchedule + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [hierarchyConfiguration]. - * - * Unlike [hierarchyConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hierarchy_configuration") - @ExcludeMissing - fun _hierarchyConfiguration(): JsonField = - hierarchyConfiguration + /** + * Returns an immutable instance of [CustomFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + private var validated: Boolean = false - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. - * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CustomFields = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [priority]. - * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + validated = true + } - /** - * Returns the raw JSON value of [productId]. - * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Returns the raw JSON value of [rolloverFraction]. - * - * Unlike [rolloverFraction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("rollover_fraction") - @ExcludeMissing - fun _rolloverFraction(): JsonField = rolloverFraction + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("specifiers") - @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + return other is CustomFields && + additionalProperties == other.additionalProperties + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode(): Int = hashCode - fun toBuilder() = Builder().from(this) + override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + } - companion object { + /** Must provide either schedule_items or recurring_schedule. */ + class Schedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditTypeId: JsonField, + private val doNotInvoice: JsonField, + private val recurringSchedule: JsonField, + private val scheduleItems: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_type_id") + @ExcludeMissing + creditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("do_not_invoice") + @ExcludeMissing + doNotInvoice: JsonField = JsonMissing.of(), + @JsonProperty("recurring_schedule") + @ExcludeMissing + recurringSchedule: JsonField = JsonMissing.of(), + @JsonProperty("schedule_items") + @ExcludeMissing + scheduleItems: JsonField> = JsonMissing.of(), + ) : this( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + mutableMapOf(), + ) /** - * Returns a mutable builder for constructing an instance of [UpdateCredit]. + * Defaults to USD (cents) if not passed. * - * The following fields are required: - * ```java - * .id() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UpdateCredit]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var accessSchedule: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var hierarchyConfiguration: JsonField = - JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var rolloverFraction: JsonField = JsonMissing.of() - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(updateCredit: UpdateCredit) = apply { - id = updateCredit.id - accessSchedule = updateCredit.accessSchedule - applicableProductIds = - updateCredit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - updateCredit.applicableProductTags.map { it.toMutableList() } - description = updateCredit.description - hierarchyConfiguration = updateCredit.hierarchyConfiguration - name = updateCredit.name - netsuiteSalesOrderId = updateCredit.netsuiteSalesOrderId - priority = updateCredit.priority - productId = updateCredit.productId - rateType = updateCredit.rateType - rolloverFraction = updateCredit.rolloverFraction - specifiers = updateCredit.specifiers.map { it.toMutableList() } - additionalProperties = updateCredit.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) + fun creditTypeId(): Optional = creditTypeId.getOptional("credit_type_id") /** - * Sets [Builder.id] to an arbitrary JSON value. + * This field is only applicable to commit invoice schedules. If true, this schedule + * will not generate an invoice. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } - - fun accessSchedule(accessSchedule: AccessSchedule) = - accessSchedule(JsonField.of(accessSchedule)) + fun doNotInvoice(): Optional = doNotInvoice.getOptional("do_not_invoice") /** - * Sets [Builder.accessSchedule] to an arbitrary JSON value. + * Enter the unit price and quantity for the charge or instead only send the amount. + * If amount is sent, the unit price is assumed to be the amount and quantity is + * inferred to be 1. * - * You should usually call [Builder.accessSchedule] with a well-typed - * [AccessSchedule] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun accessSchedule(accessSchedule: JsonField) = apply { - this.accessSchedule = accessSchedule - } + fun recurringSchedule(): Optional = + recurringSchedule.getOptional("recurring_schedule") /** - * Which products the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. + * Either provide amount or provide both unit_price and quantity. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) + fun scheduleItems(): Optional> = + scheduleItems.getOptional("schedule_items") /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. + * Returns the raw JSON value of [creditTypeId]. + * + * Unlike [creditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) + @JsonProperty("credit_type_id") + @ExcludeMissing + fun _creditTypeId(): JsonField = creditTypeId /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * Returns the raw JSON value of [doNotInvoice]. * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductIds(applicableProductIds: JsonField>) = apply { - this.applicableProductIds = applicableProductIds.map { it.toMutableList() } - } + @JsonProperty("do_not_invoice") + @ExcludeMissing + fun _doNotInvoice(): JsonField = doNotInvoice /** - * Adds a single [String] to [applicableProductIds]. + * Returns the raw JSON value of [recurringSchedule]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [recurringSchedule], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } + @JsonProperty("recurring_schedule") + @ExcludeMissing + fun _recurringSchedule(): JsonField = recurringSchedule /** - * Which tags the credit applies to. If applicable_product_ids, - * applicable_product_tags or specifiers are not provided, the credit applies to all - * products. + * Returns the raw JSON value of [scheduleItems]. + * + * Unlike [scheduleItems], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) + @JsonProperty("schedule_items") + @ExcludeMissing + fun _scheduleItems(): JsonField> = scheduleItems + + @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 [Schedule]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schedule]. */ + class Builder internal constructor() { + + private var creditTypeId: JsonField = JsonMissing.of() + private var doNotInvoice: JsonField = JsonMissing.of() + private var recurringSchedule: JsonField = JsonMissing.of() + private var scheduleItems: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schedule: Schedule) = apply { + creditTypeId = schedule.creditTypeId + doNotInvoice = schedule.doNotInvoice + recurringSchedule = schedule.recurringSchedule + scheduleItems = schedule.scheduleItems.map { it.toMutableList() } + additionalProperties = schedule.additionalProperties.toMutableMap() + } + + /** Defaults to USD (cents) if not passed. */ + fun creditTypeId(creditTypeId: String) = + creditTypeId(JsonField.of(creditTypeId)) + + /** + * Sets [Builder.creditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.creditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun creditTypeId(creditTypeId: JsonField) = apply { + this.creditTypeId = creditTypeId + } + + /** + * This field is only applicable to commit invoice schedules. If true, this + * schedule will not generate an invoice. + */ + fun doNotInvoice(doNotInvoice: Boolean) = + doNotInvoice(JsonField.of(doNotInvoice)) + + /** + * Sets [Builder.doNotInvoice] to an arbitrary JSON value. + * + * You should usually call [Builder.doNotInvoice] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun doNotInvoice(doNotInvoice: JsonField) = apply { + this.doNotInvoice = doNotInvoice + } + + /** + * Enter the unit price and quantity for the charge or instead only send the + * amount. If amount is sent, the unit price is assumed to be the amount and + * quantity is inferred to be 1. + */ + fun recurringSchedule(recurringSchedule: RecurringSchedule) = + recurringSchedule(JsonField.of(recurringSchedule)) + + /** + * Sets [Builder.recurringSchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.recurringSchedule] with a well-typed + * [RecurringSchedule] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recurringSchedule(recurringSchedule: JsonField) = apply { + this.recurringSchedule = recurringSchedule + } + + /** Either provide amount or provide both unit_price and quantity. */ + fun scheduleItems(scheduleItems: List) = + scheduleItems(JsonField.of(scheduleItems)) + + /** + * Sets [Builder.scheduleItems] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduleItems] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scheduleItems(scheduleItems: JsonField>) = apply { + this.scheduleItems = scheduleItems.map { it.toMutableList() } + } + + /** + * Adds a single [ScheduleItem] to [scheduleItems]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScheduleItem(scheduleItem: ScheduleItem) = apply { + scheduleItems = + (scheduleItems ?: JsonField.of(mutableListOf())).also { + checkKnown("scheduleItems", it).add(scheduleItem) + } + } - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = apply { - this.applicableProductTags = applicableProductTags.map { it.toMutableList() } - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - } - fun description(description: String) = description(JsonField.of(description)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Schedule = + Schedule( + creditTypeId, + doNotInvoice, + recurringSchedule, + (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - /** Optional configuration for credit hierarchy access control */ - fun hierarchyConfiguration(hierarchyConfiguration: CommitHierarchyConfiguration) = - hierarchyConfiguration(JsonField.of(hierarchyConfiguration)) + private var validated: Boolean = false /** - * Sets [Builder.hierarchyConfiguration] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.hierarchyConfiguration] with a well-typed - * [CommitHierarchyConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun hierarchyConfiguration( - hierarchyConfiguration: JsonField - ) = apply { this.hierarchyConfiguration = hierarchyConfiguration } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String?) = - netsuiteSalesOrderId(JsonField.ofNullable(netsuiteSalesOrderId)) - - /** - * Alias for calling [Builder.netsuiteSalesOrderId] with - * `netsuiteSalesOrderId.orElse(null)`. + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: Optional) = - netsuiteSalesOrderId(netsuiteSalesOrderId.getOrNull()) + fun validate(): Schedule = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. - * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId + creditTypeId() + doNotInvoice() + recurringSchedule().ifPresent { it.validate() } + scheduleItems().ifPresent { it.forEach { it.validate() } } + validated = true } - /** - * If multiple credits are applicable, the one with the lower priority will apply - * first. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Alias for [Builder.priority]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun priority(priority: Double) = priority(priority as Double?) - - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) + @JvmSynthetic + internal fun validity(): Int = + (if (creditTypeId.asKnown().isPresent) 1 else 0) + + (if (doNotInvoice.asKnown().isPresent) 1 else 0) + + (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + + (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Enter the unit price and quantity for the charge or instead only send the amount. + * If amount is sent, the unit price is assumed to be the amount and quantity is + * inferred to be 1. */ - fun priority(priority: JsonField) = apply { this.priority = priority } + class RecurringSchedule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amountDistribution: JsonField, + private val endingBefore: JsonField, + private val frequency: JsonField, + private val startingAt: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { - fun productId(productId: String) = productId(JsonField.of(productId)) + @JsonCreator + private constructor( + @JsonProperty("amount_distribution") + @ExcludeMissing + amountDistribution: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") + @ExcludeMissing + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("starting_at") + @ExcludeMissing + startingAt: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + mutableMapOf(), + ) - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun productId(productId: JsonField) = apply { this.productId = productId } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun amountDistribution(): AmountDistribution = + amountDistribution.getRequired("amount_distribution") - /** If set, the credit's rate type was updated to the specified value. */ - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** + * RFC 3339 timestamp (exclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun frequency(): Frequency = frequency.getRequired("frequency") + + /** + * RFC 3339 timestamp (inclusive). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - fun rolloverFraction(rolloverFraction: Double?) = - rolloverFraction(JsonField.ofNullable(rolloverFraction)) + /** + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - /** - * Alias for [Builder.rolloverFraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun rolloverFraction(rolloverFraction: Double) = - rolloverFraction(rolloverFraction as Double?) + /** + * Quantity for the charge. Will be multiplied by unit_price to determine the + * amount and must be specified with unit_price. If specified amount cannot be + * provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") - /** - * Alias for calling [Builder.rolloverFraction] with - * `rolloverFraction.orElse(null)`. - */ - fun rolloverFraction(rolloverFraction: Optional) = - rolloverFraction(rolloverFraction.getOrNull()) + /** + * Unit price for the charge. Will be multiplied by quantity to determine the + * amount and must be specified with quantity. If specified amount cannot be + * provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - /** - * Sets [Builder.rolloverFraction] to an arbitrary JSON value. - * - * You should usually call [Builder.rolloverFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun rolloverFraction(rolloverFraction: JsonField) = apply { - this.rolloverFraction = rolloverFraction - } + /** + * Returns the raw JSON value of [amountDistribution]. + * + * Unlike [amountDistribution], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("amount_distribution") + @ExcludeMissing + fun _amountDistribution(): JsonField = amountDistribution - /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + /** + * Returns the raw JSON value of [endingBefore]. + * + * Unlike [endingBefore], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ending_before") + @ExcludeMissing + fun _endingBefore(): JsonField = endingBefore - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency - /** - * Sets [Builder.specifiers] to an arbitrary JSON value. - * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [startingAt]. + * + * Unlike [startingAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("starting_at") + @ExcludeMissing + fun _startingAt(): JsonField = startingAt - /** - * Adds a single [CommitSpecifierInput] to [specifiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } - } + /** + * 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 - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - /** - * Returns an immutable instance of [UpdateCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateCredit = - UpdateCredit( - checkRequired("id", id), - accessSchedule, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + companion object { - private var validated: Boolean = false + /** + * Returns a mutable builder for constructing an instance of + * [RecurringSchedule]. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): UpdateCredit = apply { - if (validated) { - return@apply - } + /** A builder for [RecurringSchedule]. */ + class Builder internal constructor() { + + private var amountDistribution: JsonField? = null + private var endingBefore: JsonField? = null + private var frequency: JsonField? = null + private var startingAt: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(recurringSchedule: RecurringSchedule) = apply { + amountDistribution = recurringSchedule.amountDistribution + endingBefore = recurringSchedule.endingBefore + frequency = recurringSchedule.frequency + startingAt = recurringSchedule.startingAt + amount = recurringSchedule.amount + quantity = recurringSchedule.quantity + unitPrice = recurringSchedule.unitPrice + additionalProperties = + recurringSchedule.additionalProperties.toMutableMap() + } - id() - accessSchedule().ifPresent { it.validate() } - applicableProductIds() - applicableProductTags() - description() - hierarchyConfiguration().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - priority() - productId() - rateType().ifPresent { it.validate() } - rolloverFraction() - specifiers().ifPresent { it.forEach { it.validate() } } - validated = true - } + fun amountDistribution(amountDistribution: AmountDistribution) = + amountDistribution(JsonField.of(amountDistribution)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.amountDistribution] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDistribution] with a well-typed + * [AmountDistribution] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun amountDistribution(amountDistribution: JsonField) = + apply { + this.amountDistribution = amountDistribution + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (hierarchyConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + - (if (rolloverFraction.asKnown().isPresent) 1 else 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** RFC 3339 timestamp (exclusive). */ + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) - class AccessSchedule - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addScheduleItems: JsonField>, - private val removeScheduleItems: JsonField>, - private val updateScheduleItems: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.endingBefore] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBefore] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore + } - @JsonCreator - private constructor( - @JsonProperty("add_schedule_items") - @ExcludeMissing - addScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("remove_schedule_items") - @ExcludeMissing - removeScheduleItems: JsonField> = JsonMissing.of(), - @JsonProperty("update_schedule_items") - @ExcludeMissing - updateScheduleItems: JsonField> = JsonMissing.of(), - ) : this(addScheduleItems, removeScheduleItems, updateScheduleItems, mutableMapOf()) + fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun addScheduleItems(): Optional> = - addScheduleItems.getOptional("add_schedule_items") + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [Frequency] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun removeScheduleItems(): Optional> = - removeScheduleItems.getOptional("remove_schedule_items") + /** RFC 3339 timestamp (inclusive). */ + fun startingAt(startingAt: OffsetDateTime) = + startingAt(JsonField.of(startingAt)) - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun updateScheduleItems(): Optional> = - updateScheduleItems.getOptional("update_schedule_items") + /** + * Sets [Builder.startingAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startingAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startingAt(startingAt: JsonField) = apply { + this.startingAt = startingAt + } - /** - * Returns the raw JSON value of [addScheduleItems]. - * - * Unlike [addScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_schedule_items") - @ExcludeMissing - fun _addScheduleItems(): JsonField> = addScheduleItems + /** + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the amount + * and quantity is inferred to be 1. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) - /** - * Returns the raw JSON value of [removeScheduleItems]. - * - * Unlike [removeScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_schedule_items") - @ExcludeMissing - fun _removeScheduleItems(): JsonField> = - removeScheduleItems + /** + * 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 } - /** - * Returns the raw JSON value of [updateScheduleItems]. - * - * Unlike [updateScheduleItems], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("update_schedule_items") - @ExcludeMissing - fun _updateScheduleItems(): JsonField> = - updateScheduleItems + /** + * Quantity for the charge. Will be multiplied by unit_price to determine + * the amount and must be specified with unit_price. If specified amount + * cannot be provided. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Unit price for the charge. Will be multiplied by quantity to determine + * the amount and must be specified with quantity. If specified amount + * cannot be provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } - companion object { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns a mutable builder for constructing an instance of [AccessSchedule]. - */ - @JvmStatic fun builder() = Builder() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** A builder for [AccessSchedule]. */ - class Builder internal constructor() { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - private var addScheduleItems: JsonField>? = null - private var removeScheduleItems: JsonField>? = - null - private var updateScheduleItems: JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmSynthetic - internal fun from(accessSchedule: AccessSchedule) = apply { - addScheduleItems = - accessSchedule.addScheduleItems.map { it.toMutableList() } - removeScheduleItems = - accessSchedule.removeScheduleItems.map { it.toMutableList() } - updateScheduleItems = - accessSchedule.updateScheduleItems.map { it.toMutableList() } - additionalProperties = accessSchedule.additionalProperties.toMutableMap() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecurringSchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDistribution() + * .endingBefore() + * .frequency() + * .startingAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RecurringSchedule = + RecurringSchedule( + checkRequired("amountDistribution", amountDistribution), + checkRequired("endingBefore", endingBefore), + checkRequired("frequency", frequency), + checkRequired("startingAt", startingAt), + amount, + quantity, + unitPrice, + additionalProperties.toMutableMap(), + ) } - fun addScheduleItems(addScheduleItems: List) = - addScheduleItems(JsonField.of(addScheduleItems)) + private var validated: Boolean = false /** - * Sets [Builder.addScheduleItems] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.addScheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun addScheduleItems(addScheduleItems: JsonField>) = - apply { - this.addScheduleItems = addScheduleItems.map { it.toMutableList() } + fun validate(): RecurringSchedule = apply { + if (validated) { + return@apply } - /** - * Adds a single [AddScheduleItem] to [addScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAddScheduleItem(addScheduleItem: AddScheduleItem) = apply { - addScheduleItems = - (addScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("addScheduleItems", it).add(addScheduleItem) - } + amountDistribution().validate() + endingBefore() + frequency().validate() + startingAt() + amount() + quantity() + unitPrice() + validated = true } - fun removeScheduleItems(removeScheduleItems: List) = - removeScheduleItems(JsonField.of(removeScheduleItems)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.removeScheduleItems] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.removeScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun removeScheduleItems( - removeScheduleItems: JsonField> - ) = apply { - this.removeScheduleItems = removeScheduleItems.map { it.toMutableList() } - } + @JvmSynthetic + internal fun validity(): Int = + (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (frequency.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingAt.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - /** - * Adds a single [RemoveScheduleItem] to [removeScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRemoveScheduleItem(removeScheduleItem: RemoveScheduleItem) = apply { - removeScheduleItems = - (removeScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("removeScheduleItems", it).add(removeScheduleItem) - } - } + class AmountDistribution + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun updateScheduleItems(updateScheduleItems: List) = - updateScheduleItems(JsonField.of(updateScheduleItems)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Sets [Builder.updateScheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.updateScheduleItems] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun updateScheduleItems( - updateScheduleItems: JsonField> - ) = apply { - this.updateScheduleItems = updateScheduleItems.map { it.toMutableList() } - } + companion object { - /** - * Adds a single [UpdateScheduleItem] to [updateScheduleItems]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addUpdateScheduleItem(updateScheduleItem: UpdateScheduleItem) = apply { - updateScheduleItems = - (updateScheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("updateScheduleItems", it).add(updateScheduleItem) - } - } + @JvmField val DIVIDED = of("DIVIDED") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val EACH = of("EACH") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JvmStatic + fun of(value: String) = AmountDistribution(JsonField.of(value)) + } + + /** An enum containing [AmountDistribution]'s known values. */ + enum class Known { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + } + + /** + * An enum containing [AmountDistribution]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AmountDistribution] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDED, + DIVIDED_ROUNDED, + EACH, + /** + * An enum member indicating that [AmountDistribution] was instantiated + * with an unknown value. + */ + _UNKNOWN, } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDED -> Value.DIVIDED + DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED + EACH -> Value.EACH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DIVIDED -> Known.DIVIDED + DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED + EACH -> Known.EACH + else -> + throw MetronomeInvalidDataException( + "Unknown AmountDistribution: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): AmountDistribution = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * Returns an immutable instance of [AccessSchedule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessSchedule = - AccessSchedule( - (addScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (removeScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - (updateScheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AccessSchedule = apply { - if (validated) { - return@apply - } + return other is AmountDistribution && value == other.value + } - addScheduleItems().ifPresent { it.forEach { it.validate() } } - removeScheduleItems().ifPresent { it.forEach { it.validate() } } - updateScheduleItems().ifPresent { it.forEach { it.validate() } } - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + override fun toString() = value.toString() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (removeScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (updateScheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) - - class AddScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - + class Frequency @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(amount, endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if 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") + private constructor(private val value: JsonField) : Enum { - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") + companion object { - /** - * 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 + @JvmField val MONTHLY = of("MONTHLY") - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + @JvmField val QUARTERLY = of("QUARTERLY") - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val ANNUAL = of("ANNUAL") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val WEEKLY = of("WEEKLY") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) + } - companion object { + /** An enum containing [Frequency]'s known values. */ + enum class Known { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + } /** - * Returns a mutable builder for constructing an instance of - * [AddScheduleItem]. + * An enum containing [Frequency]'s known values, as well as an [_UNKNOWN] + * member. * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` + * An instance of [Frequency] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddScheduleItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var endingBefore: JsonField? = null - private var startingAt: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(addScheduleItem: AddScheduleItem) = apply { - amount = addScheduleItem.amount - endingBefore = addScheduleItem.endingBefore - startingAt = addScheduleItem.startingAt - additionalProperties = - addScheduleItem.additionalProperties.toMutableMap() + enum class Value { + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + WEEKLY, + /** + * An enum member indicating that [Frequency] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - fun amount(amount: Double) = amount(JsonField.of(amount)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + WEEKLY -> Value.WEEKLY + else -> Value._UNKNOWN + } /** - * Sets [Builder.amount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's 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. + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + fun known(): Known = + when (this) { + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + WEEKLY -> Known.WEEKLY + else -> + throw MetronomeInvalidDataException("Unknown Frequency: $value") + } /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + private var validated: Boolean = false /** - * Sets [Builder.startingAt] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): Frequency = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns an immutable instance of [AddScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .endingBefore() - * .startingAt() - * ``` + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): AddScheduleItem = - AddScheduleItem( - checkRequired("amount", amount), - checkRequired("endingBefore", endingBefore), - checkRequired("startingAt", startingAt), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): AddScheduleItem = apply { - if (validated) { - return@apply + return other is Frequency && value == other.value } - amount() - endingBefore() - startingAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AddScheduleItem && - amount == other.amount && + return other is RecurringSchedule && + amountDistribution == other.amountDistribution && endingBefore == other.endingBefore && + frequency == other.frequency && startingAt == other.startingAt && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(amount, endingBefore, startingAt, additionalProperties) + Objects.hash( + amountDistribution, + endingBefore, + frequency, + startingAt, + amount, + quantity, + unitPrice, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "AddScheduleItem{amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" + "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class RemoveScheduleItem + class ScheduleItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val id: JsonField, + private val timestamp: JsonField, + private val amount: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + + /** + * timestamp of the scheduled event + * + * @throws MetronomeInvalidDataException if 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") + + /** + * Amount for the charge. Can be provided instead of unit_price and quantity. If + * amount is sent, the unit_price is assumed to be the amount and quantity is + * inferred to be 1. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Quantity for the charge. Will be multiplied by unit_price to determine the + * amount and must be specified with unit_price. If specified amount cannot be + * provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Unit price for the charge. Will be multiplied by quantity to determine the + * amount and must be specified with quantity. If specified amount cannot be + * provided. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * 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 [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun id(): String = id.getRequired("id") + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -24331,41 +29211,101 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [RemoveScheduleItem]. + * Returns a mutable builder for constructing an instance of [ScheduleItem]. * * The following fields are required: * ```java - * .id() + * .timestamp() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemoveScheduleItem]. */ + /** A builder for [ScheduleItem]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var timestamp: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeScheduleItem: RemoveScheduleItem) = apply { - id = removeScheduleItem.id - additionalProperties = - removeScheduleItem.additionalProperties.toMutableMap() + internal fun from(scheduleItem: ScheduleItem) = apply { + timestamp = scheduleItem.timestamp + amount = scheduleItem.amount + quantity = scheduleItem.quantity + unitPrice = scheduleItem.unitPrice + additionalProperties = scheduleItem.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + /** timestamp of the scheduled event */ + fun timestamp(timestamp: OffsetDateTime) = + timestamp(JsonField.of(timestamp)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.timestamp] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] 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 + } + + /** + * Amount for the charge. Can be provided instead of unit_price and + * quantity. If amount is sent, the unit_price is assumed to be the amount + * and quantity is inferred to be 1. + */ + 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 id(id: JsonField) = apply { this.id = id } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * Quantity for the charge. Will be multiplied by unit_price to determine + * the amount and must be specified with unit_price. If specified amount + * cannot be provided. + */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { + this.quantity = quantity + } + + /** + * Unit price for the charge. Will be multiplied by quantity to determine + * the amount and must be specified with quantity. If specified amount + * cannot be provided. + */ + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } fun additionalProperties(additionalProperties: Map) = apply { @@ -24390,20 +29330,23 @@ private constructor( } /** - * Returns an immutable instance of [RemoveScheduleItem]. + * Returns an immutable instance of [ScheduleItem]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() + * .timestamp() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RemoveScheduleItem = - RemoveScheduleItem( - checkRequired("id", id), + fun build(): ScheduleItem = + ScheduleItem( + checkRequired("timestamp", timestamp), + amount, + quantity, + unitPrice, additionalProperties.toMutableMap(), ) } @@ -24414,911 +29357,1071 @@ private constructor( * Validates that the types of all values in this object match their expected * types recursively. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): RemoveScheduleItem = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveScheduleItem && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveScheduleItem{id=$id, additionalProperties=$additionalProperties}" - } - - class UpdateScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val amount: JsonField, - private val endingBefore: JsonField, - private val startingAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), - ) : this(id, amount, endingBefore, startingAt, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * RFC 3339 timestamp (exclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = - endingBefore.getOptional("ending_before") - - /** - * RFC 3339 timestamp (inclusive) - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun startingAt(): Optional = - startingAt.getOptional("starting_at") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [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 [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore + fun validate(): ScheduleItem = apply { + if (validated) { + return@apply + } + + timestamp() + amount() + quantity() + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [startingAt]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + @JvmSynthetic + internal fun validity(): Int = + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScheduleItem && + timestamp == other.timestamp && + amount == other.amount && + quantity == other.quantity && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } - /** - * Returns a mutable builder for constructing an instance of - * [UpdateScheduleItem]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [UpdateScheduleItem]. */ - class Builder internal constructor() { + return other is Schedule && + creditTypeId == other.creditTypeId && + doNotInvoice == other.doNotInvoice && + recurringSchedule == other.recurringSchedule && + scheduleItems == other.scheduleItems && + additionalProperties == other.additionalProperties + } - private var id: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var startingAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash( + creditTypeId, + doNotInvoice, + recurringSchedule, + scheduleItems, + additionalProperties, + ) + } - @JvmSynthetic - internal fun from(updateScheduleItem: UpdateScheduleItem) = apply { - id = updateScheduleItem.id - amount = updateScheduleItem.amount - endingBefore = updateScheduleItem.endingBefore - startingAt = updateScheduleItem.startingAt - additionalProperties = - updateScheduleItem.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun id(id: String) = id(JsonField.of(id)) + override fun toString() = + "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun amount(amount: Double) = amount(JsonField.of(amount)) + return other is UpdateDiscount && + id == other.id && + customFields == other.customFields && + name == other.name && + netsuiteSalesOrderId == other.netsuiteSalesOrderId && + schedule == other.schedule && + additionalProperties == other.additionalProperties + } - /** - * 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 } + private val hashCode: Int by lazy { + Objects.hash( + id, + customFields, + name, + netsuiteSalesOrderId, + schedule, + additionalProperties, + ) + } - /** RFC 3339 timestamp (exclusive) */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + override fun toString() = + "UpdateDiscount{id=$id, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, schedule=$schedule, additionalProperties=$additionalProperties}" + } - /** RFC 3339 timestamp (inclusive) */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + class UpdatePrepaidBalanceThresholdConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val commit: JsonField, + private val customCreditTypeId: JsonField, + private val discountConfiguration: JsonField, + private val isEnabled: JsonField, + private val paymentGateConfig: JsonField, + private val rechargeToAmount: JsonField, + private val thresholdAmount: JsonField, + private val thresholdBalanceSpecifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt - } + @JsonCreator + private constructor( + @JsonProperty("commit") + @ExcludeMissing + commit: JsonField = JsonMissing.of(), + @JsonProperty("custom_credit_type_id") + @ExcludeMissing + customCreditTypeId: JsonField = JsonMissing.of(), + @JsonProperty("discount_configuration") + @ExcludeMissing + discountConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("is_enabled") + @ExcludeMissing + isEnabled: JsonField = JsonMissing.of(), + @JsonProperty("payment_gate_config") + @ExcludeMissing + paymentGateConfig: JsonField = JsonMissing.of(), + @JsonProperty("recharge_to_amount") + @ExcludeMissing + rechargeToAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("threshold_balance_specifiers") + @ExcludeMissing + thresholdBalanceSpecifiers: JsonField> = + JsonMissing.of(), + ) : this( + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, + mutableMapOf(), + ) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun commit(): Optional = commit.getOptional("commit") + + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold commit + * amount will be in terms of this credit type instead of the fiat currency. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customCreditTypeId(): Optional = + customCreditTypeId.getOptional("custom_credit_type_id") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun discountConfiguration(): Optional = + discountConfiguration.getOptional("discount_configuration") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * When set to false, the contract will not be evaluated against the threshold_amount. + * Toggling to true will result an immediate evaluation, regardless of prior state. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun paymentGateConfig(): Optional = + paymentGateConfig.getOptional("payment_gate_config") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Specify the amount the balance should be recharged to. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rechargeToAmount(): Optional = + rechargeToAmount.getOptional("recharge_to_amount") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Specify the threshold amount for the contract. Each time the contract's balance + * lowers to this amount, a threshold charge will be initiated. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thresholdAmount(): Optional = + thresholdAmount.getOptional("threshold_amount") - /** - * Returns an immutable instance of [UpdateScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateScheduleItem = - UpdateScheduleItem( - checkRequired("id", id), - amount, - endingBefore, - startingAt, - additionalProperties.toMutableMap(), - ) - } + /** + * Determines which balances are excluded from remaining balance calculation for + * threshold billing. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thresholdBalanceSpecifiers(): Optional> = + thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") - private var validated: Boolean = false + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): UpdateScheduleItem = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [customCreditTypeId]. + * + * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("custom_credit_type_id") + @ExcludeMissing + fun _customCreditTypeId(): JsonField = customCreditTypeId - id() - amount() - endingBefore() - startingAt() - validated = true - } + /** + * Returns the raw JSON value of [discountConfiguration]. + * + * Unlike [discountConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_configuration") + @ExcludeMissing + fun _discountConfiguration(): JsonField = discountConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [isEnabled]. + * + * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("is_enabled") + @ExcludeMissing + fun _isEnabled(): JsonField = isEnabled - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [paymentGateConfig]. + * + * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_gate_config") + @ExcludeMissing + fun _paymentGateConfig(): JsonField = paymentGateConfig - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [rechargeToAmount]. + * + * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recharge_to_amount") + @ExcludeMissing + fun _rechargeToAmount(): JsonField = rechargeToAmount - return other is UpdateScheduleItem && - id == other.id && - amount == other.amount && - endingBefore == other.endingBefore && - startingAt == other.startingAt && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount - private val hashCode: Int by lazy { - Objects.hash(id, amount, endingBefore, startingAt, additionalProperties) - } + /** + * Returns the raw JSON value of [thresholdBalanceSpecifiers]. + * + * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_balance_specifiers") + @ExcludeMissing + fun _thresholdBalanceSpecifiers(): JsonField> = + thresholdBalanceSpecifiers - override fun hashCode(): Int = hashCode + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString() = - "UpdateScheduleItem{id=$id, amount=$amount, endingBefore=$endingBefore, startingAt=$startingAt, additionalProperties=$additionalProperties}" - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) - return other is AccessSchedule && - addScheduleItems == other.addScheduleItems && - removeScheduleItems == other.removeScheduleItems && - updateScheduleItems == other.updateScheduleItems && - additionalProperties == other.additionalProperties - } + companion object { - private val hashCode: Int by lazy { - Objects.hash( - addScheduleItems, - removeScheduleItems, - updateScheduleItems, - additionalProperties, - ) - } + /** + * Returns a mutable builder for constructing an instance of + * [UpdatePrepaidBalanceThresholdConfiguration]. + */ + @JvmStatic fun builder() = Builder() + } - override fun hashCode(): Int = hashCode + /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + class Builder internal constructor() { + + private var commit: JsonField = JsonMissing.of() + private var customCreditTypeId: JsonField = JsonMissing.of() + private var discountConfiguration: JsonField = + JsonMissing.of() + private var isEnabled: JsonField = JsonMissing.of() + private var paymentGateConfig: JsonField = JsonMissing.of() + private var rechargeToAmount: JsonField = JsonMissing.of() + private var thresholdAmount: JsonField = JsonMissing.of() + private var thresholdBalanceSpecifiers: + JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "AccessSchedule{addScheduleItems=$addScheduleItems, removeScheduleItems=$removeScheduleItems, updateScheduleItems=$updateScheduleItems, additionalProperties=$additionalProperties}" - } + @JvmSynthetic + internal fun from( + updatePrepaidBalanceThresholdConfiguration: + UpdatePrepaidBalanceThresholdConfiguration + ) = apply { + commit = updatePrepaidBalanceThresholdConfiguration.commit + customCreditTypeId = + updatePrepaidBalanceThresholdConfiguration.customCreditTypeId + discountConfiguration = + updatePrepaidBalanceThresholdConfiguration.discountConfiguration + isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled + paymentGateConfig = updatePrepaidBalanceThresholdConfiguration.paymentGateConfig + rechargeToAmount = updatePrepaidBalanceThresholdConfiguration.rechargeToAmount + thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount + thresholdBalanceSpecifiers = + updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers.map { + it.toMutableList() + } + additionalProperties = + updatePrepaidBalanceThresholdConfiguration.additionalProperties + .toMutableMap() + } - /** If set, the credit's rate type was updated to the specified value. */ - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun commit(commit: Commit) = commit(JsonField.of(commit)) /** - * Returns this class instance's raw value. + * Sets [Builder.commit] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * You should usually call [Builder.commit] with a well-typed [Commit] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun commit(commit: JsonField) = apply { this.commit = commit } - @JvmField val LIST_RATE = of("LIST_RATE") + /** + * If provided, the threshold, recharge-to amount, and the resulting threshold + * commit amount will be in terms of this credit type instead of the fiat currency. + */ + fun customCreditTypeId(customCreditTypeId: String?) = + customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) - @JvmField val COMMIT_RATE = of("COMMIT_RATE") + /** + * Alias for calling [Builder.customCreditTypeId] with + * `customCreditTypeId.orElse(null)`. + */ + fun customCreditTypeId(customCreditTypeId: Optional) = + customCreditTypeId(customCreditTypeId.getOrNull()) - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + /** + * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.customCreditTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCreditTypeId(customCreditTypeId: JsonField) = apply { + this.customCreditTypeId = customCreditTypeId } - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } + fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = + discountConfiguration(JsonField.ofNullable(discountConfiguration)) /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Alias for calling [Builder.discountConfiguration] with + * `discountConfiguration.orElse(null)`. */ - enum class Value { - LIST_RATE, - COMMIT_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun discountConfiguration(discountConfiguration: Optional) = + discountConfiguration(discountConfiguration.getOrNull()) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.discountConfiguration] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * You should usually call [Builder.discountConfiguration] with a well-typed + * [DiscountConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN + fun discountConfiguration(discountConfiguration: JsonField) = + apply { + this.discountConfiguration = discountConfiguration } /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. + * When set to false, the contract will not be evaluated against the + * threshold_amount. Toggling to true will result an immediate evaluation, + * regardless of prior state. */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") - } + fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.isEnabled] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. + * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + fun isEnabled(isEnabled: JsonField) = apply { this.isEnabled = isEnabled } - private var validated: Boolean = false + fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = + paymentGateConfig(JsonField.of(paymentGateConfig)) /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. + * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. + * You should usually call [Builder.paymentGateConfig] with a well-typed + * [PaymentGateConfigV2] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun validate(): RateType = apply { - if (validated) { - return@apply - } - - known() - validated = true + fun paymentGateConfig(paymentGateConfig: JsonField) = apply { + this.paymentGateConfig = paymentGateConfig } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** Specify the amount the balance should be recharged to. */ + fun rechargeToAmount(rechargeToAmount: Double) = + rechargeToAmount(JsonField.of(rechargeToAmount)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun rechargeToAmount(rechargeToAmount: JsonField) = apply { + this.rechargeToAmount = rechargeToAmount } - return other is UpdateCredit && - id == other.id && - accessSchedule == other.accessSchedule && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - description == other.description && - hierarchyConfiguration == other.hierarchyConfiguration && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - priority == other.priority && - productId == other.productId && - rateType == other.rateType && - rolloverFraction == other.rolloverFraction && - specifiers == other.specifiers && - additionalProperties == other.additionalProperties - } + /** + * Specify the threshold amount for the contract. Each time the contract's balance + * lowers to this amount, a threshold charge will be initiated. + */ + fun thresholdAmount(thresholdAmount: Double) = + thresholdAmount(JsonField.of(thresholdAmount)) - private val hashCode: Int by lazy { - Objects.hash( - id, - accessSchedule, - applicableProductIds, - applicableProductTags, - description, - hierarchyConfiguration, - name, - netsuiteSalesOrderId, - priority, - productId, - rateType, - rolloverFraction, - specifiers, - additionalProperties, - ) - } + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } - override fun hashCode(): Int = hashCode + /** + * Determines which balances are excluded from remaining balance calculation for + * threshold billing. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: List? + ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) - override fun toString() = - "UpdateCredit{id=$id, accessSchedule=$accessSchedule, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, description=$description, hierarchyConfiguration=$hierarchyConfiguration, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, priority=$priority, productId=$productId, rateType=$rateType, rolloverFraction=$rolloverFraction, specifiers=$specifiers, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [Builder.thresholdBalanceSpecifiers] with + * `thresholdBalanceSpecifiers.orElse(null)`. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: Optional> + ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) - class UpdateDiscount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val customFields: JsonField, - private val name: JsonField, - private val netsuiteSalesOrderId: JsonField, - private val schedule: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdBalanceSpecifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun thresholdBalanceSpecifiers( + thresholdBalanceSpecifiers: JsonField> + ) = apply { + this.thresholdBalanceSpecifiers = + thresholdBalanceSpecifiers.map { it.toMutableList() } + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - netsuiteSalesOrderId: JsonField = JsonMissing.of(), - @JsonProperty("schedule") - @ExcludeMissing - schedule: JsonField = JsonMissing.of(), - ) : this(id, customFields, name, netsuiteSalesOrderId, schedule, mutableMapOf()) + /** + * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdBalanceSpecifier( + thresholdBalanceSpecifier: ThresholdBalanceSpecifier + ) = apply { + thresholdBalanceSpecifiers = + (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdBalanceSpecifiers", it) + .add(thresholdBalanceSpecifier) + } + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Custom fields to be added eg. { "key1": "value1", "key2": "value2" } - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customFields(): Optional = customFields.getOptional("custom_fields") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun netsuiteSalesOrderId(): Optional = - netsuiteSalesOrderId.getOptional("netsuite_sales_order_id") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Must provide either schedule_items or recurring_schedule. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun schedule(): Optional = schedule.getOptional("schedule") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns an immutable instance of [UpdatePrepaidBalanceThresholdConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdatePrepaidBalanceThresholdConfiguration = + UpdatePrepaidBalanceThresholdConfiguration( + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField = customFields + private var validated: Boolean = false /** - * Returns the raw JSON value of [name]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [netsuiteSalesOrderId]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * Unlike [netsuiteSalesOrderId], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws MetronomeInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JsonProperty("netsuite_sales_order_id") - @ExcludeMissing - fun _netsuiteSalesOrderId(): JsonField = netsuiteSalesOrderId + fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + if (validated) { + return@apply + } + + commit().ifPresent { it.validate() } + customCreditTypeId() + discountConfiguration().ifPresent { it.validate() } + isEnabled() + paymentGateConfig().ifPresent { it.validate() } + rechargeToAmount() + thresholdAmount() + thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [schedule]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [schedule], this method doesn't throw if the JSON field has an unexpected - * type. + * Used for best match union deserialization. */ - @JsonProperty("schedule") - @ExcludeMissing - fun _schedule(): JsonField = schedule + @JvmSynthetic + internal fun validity(): Int = + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + + (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (isEnabled.asKnown().isPresent) 1 else 0) + + (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + class Commit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val name: JsonField, + private val priority: JsonField, + private val productId: JsonField, + private val applicableProductIds: JsonField>, + private val applicableProductTags: JsonField>, + private val specifiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + productId: JsonField = JsonMissing.of(), + @JsonProperty("applicable_product_ids") + @ExcludeMissing + applicableProductIds: JsonField> = JsonMissing.of(), + @JsonProperty("applicable_product_tags") + @ExcludeMissing + applicableProductTags: JsonField> = JsonMissing.of(), + @JsonProperty("specifiers") + @ExcludeMissing + specifiers: JsonField> = JsonMissing.of(), + ) : this( + description, + name, + priority, + productId, + applicableProductIds, + applicableProductTags, + specifiers, + mutableMapOf(), + ) - fun toBuilder() = Builder().from(this) + fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = + UpdateBaseThresholdCommit.builder() + .description(description) + .name(name) + .priority(priority) + .productId(productId) + .build() - companion object { + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") /** - * Returns a mutable builder for constructing an instance of [UpdateDiscount]. + * Specify the name of the line item for the threshold charge. If left blank, it + * will default to the commit product name. * - * The following fields are required: - * ```java - * .id() - * ``` + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UpdateDiscount]. */ - class Builder internal constructor() { + fun name(): Optional = name.getOptional("name") - private var id: JsonField? = null - private var customFields: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netsuiteSalesOrderId: JsonField = JsonMissing.of() - private var schedule: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The priority of the commit, used to determine drawdown order. Lower priority + * commits are consumed first. Defaults to 100 if not specified. On updates, set to + * null to clear a previously configured priority. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") - @JvmSynthetic - internal fun from(updateDiscount: UpdateDiscount) = apply { - id = updateDiscount.id - customFields = updateDiscount.customFields - name = updateDiscount.name - netsuiteSalesOrderId = updateDiscount.netsuiteSalesOrderId - schedule = updateDiscount.schedule - additionalProperties = updateDiscount.additionalProperties.toMutableMap() - } + /** + * The commit product that will be used to generate the line item for commit + * payment. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun productId(): Optional = productId.getOptional("product_id") - fun id(id: String) = id(JsonField.of(id)) + /** + * Which products the threshold commit applies to. If both applicable_product_ids + * and applicable_product_tags are not provided, the commit applies to all products. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicableProductIds(): Optional> = + applicableProductIds.getOptional("applicable_product_ids") /** - * Sets [Builder.id] to an arbitrary JSON value. + * Which tags the threshold commit applies to. If both applicable_product_ids and + * applicable_product_tags are not provided, the commit applies to all products. * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun id(id: JsonField) = apply { this.id = id } + fun applicableProductTags(): Optional> = + applicableProductTags.getOptional("applicable_product_tags") - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - fun customFields(customFields: CustomFields) = - customFields(JsonField.of(customFields)) + /** + * List of filters that determine what kind of customer usage draws down a commit or + * credit. A customer's usage needs to meet the condition of at least one of the + * specifiers to contribute to a commit's or credit's drawdown. This field cannot be + * used together with `applicable_product_ids` or `applicable_product_tags`. + * Instead, to target usage by product or product tag, pass those values in the body + * of `specifiers`. + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun specifiers(): Optional> = + specifiers.getOptional("specifiers") /** - * Sets [Builder.customFields] to an arbitrary JSON value. + * Returns the raw JSON value of [description]. * - * You should usually call [Builder.customFields] with a well-typed [CustomFields] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun customFields(customFields: JsonField) = apply { - this.customFields = customFields - } + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Sets [Builder.name] to an arbitrary JSON value. + * Returns the raw JSON value of [priority]. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun name(name: JsonField) = apply { this.name = name } + @JsonProperty("priority") + @ExcludeMissing + fun _priority(): JsonField = priority - fun netsuiteSalesOrderId(netsuiteSalesOrderId: String) = - netsuiteSalesOrderId(JsonField.of(netsuiteSalesOrderId)) + /** + * Returns the raw JSON value of [productId]. + * + * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("product_id") + @ExcludeMissing + fun _productId(): JsonField = productId /** - * Sets [Builder.netsuiteSalesOrderId] to an arbitrary JSON value. + * Returns the raw JSON value of [applicableProductIds]. * - * You should usually call [Builder.netsuiteSalesOrderId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun netsuiteSalesOrderId(netsuiteSalesOrderId: JsonField) = apply { - this.netsuiteSalesOrderId = netsuiteSalesOrderId - } + @JsonProperty("applicable_product_ids") + @ExcludeMissing + fun _applicableProductIds(): JsonField> = applicableProductIds - /** Must provide either schedule_items or recurring_schedule. */ - fun schedule(schedule: Schedule) = schedule(JsonField.of(schedule)) + /** + * Returns the raw JSON value of [applicableProductTags]. + * + * Unlike [applicableProductTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applicable_product_tags") + @ExcludeMissing + fun _applicableProductTags(): JsonField> = applicableProductTags /** - * Sets [Builder.schedule] to an arbitrary JSON value. + * Returns the raw JSON value of [specifiers]. * - * You should usually call [Builder.schedule] with a well-typed [Schedule] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [specifiers], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun schedule(schedule: JsonField) = apply { this.schedule = schedule } + @JsonProperty("specifiers") + @ExcludeMissing + fun _specifiers(): JsonField> = specifiers - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @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 [Commit]. */ + @JvmStatic fun builder() = Builder() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var applicableProductIds: JsonField>? = null + private var applicableProductTags: JsonField>? = null + private var specifiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + description = commit.description + name = commit.name + priority = commit.priority + productId = commit.productId + applicableProductIds = + commit.applicableProductIds.map { it.toMutableList() } + applicableProductTags = + commit.applicableProductTags.map { it.toMutableList() } + specifiers = commit.specifiers.map { it.toMutableList() } + additionalProperties = commit.additionalProperties.toMutableMap() + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Specify the name of the line item for the threshold charge. If left blank, it + * will default to the commit product name. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The priority of the commit, used to determine drawdown order. Lower priority + * commits are consumed first. Defaults to 100 if not specified. On updates, set + * to null to clear a previously configured priority. + */ + fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for [Builder.priority]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun priority(priority: Double) = priority(priority as Double?) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } - /** - * Returns an immutable instance of [UpdateDiscount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateDiscount = - UpdateDiscount( - checkRequired("id", id), - customFields, - name, - netsuiteSalesOrderId, - schedule, - additionalProperties.toMutableMap(), - ) - } + /** + * The commit product that will be used to generate the line item for commit + * payment. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) - private var validated: Boolean = false + /** + * Sets [Builder.productId] to an arbitrary JSON value. + * + * You should usually call [Builder.productId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productId(productId: JsonField) = apply { + this.productId = productId + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): UpdateDiscount = apply { - if (validated) { - return@apply - } + /** + * Which products the threshold commit applies to. If both + * applicable_product_ids and applicable_product_tags are not provided, the + * commit applies to all products. + */ + fun applicableProductIds(applicableProductIds: List?) = + applicableProductIds(JsonField.ofNullable(applicableProductIds)) - id() - customFields().ifPresent { it.validate() } - name() - netsuiteSalesOrderId() - schedule().ifPresent { it.validate() } - validated = true - } + /** + * Alias for calling [Builder.applicableProductIds] with + * `applicableProductIds.orElse(null)`. + */ + fun applicableProductIds(applicableProductIds: Optional>) = + applicableProductIds(applicableProductIds.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * Sets [Builder.applicableProductIds] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductIds(applicableProductIds: JsonField>) = + apply { + this.applicableProductIds = + applicableProductIds.map { it.toMutableList() } + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (netsuiteSalesOrderId.asKnown().isPresent) 1 else 0) + - (schedule.asKnown().getOrNull()?.validity() ?: 0) + /** + * Adds a single [String] to [applicableProductIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductId(applicableProductId: String) = apply { + applicableProductIds = + (applicableProductIds ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductIds", it).add(applicableProductId) + } + } - /** Custom fields to be added eg. { "key1": "value1", "key2": "value2" } */ - class CustomFields - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Which tags the threshold commit applies to. If both applicable_product_ids + * and applicable_product_tags are not provided, the commit applies to all + * products. + */ + fun applicableProductTags(applicableProductTags: List?) = + applicableProductTags(JsonField.ofNullable(applicableProductTags)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Alias for calling [Builder.applicableProductTags] with + * `applicableProductTags.orElse(null)`. + */ + fun applicableProductTags(applicableProductTags: Optional>) = + applicableProductTags(applicableProductTags.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.applicableProductTags] to an arbitrary JSON value. + * + * You should usually call [Builder.applicableProductTags] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun applicableProductTags(applicableProductTags: JsonField>) = + apply { + this.applicableProductTags = + applicableProductTags.map { it.toMutableList() } + } - companion object { + /** + * Adds a single [String] to [applicableProductTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addApplicableProductTag(applicableProductTag: String) = apply { + applicableProductTags = + (applicableProductTags ?: JsonField.of(mutableListOf())).also { + checkKnown("applicableProductTags", it).add(applicableProductTag) + } + } - /** Returns a mutable builder for constructing an instance of [CustomFields]. */ - @JvmStatic fun builder() = Builder() - } + /** + * List of filters that determine what kind of customer usage draws down a + * commit or credit. A customer's usage needs to meet the condition of at least + * one of the specifiers to contribute to a commit's or credit's drawdown. This + * field cannot be used together with `applicable_product_ids` or + * `applicable_product_tags`. Instead, to target usage by product or product + * tag, pass those values in the body of `specifiers`. + */ + fun specifiers(specifiers: List?) = + specifiers(JsonField.ofNullable(specifiers)) - /** A builder for [CustomFields]. */ - class Builder internal constructor() { + /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ + fun specifiers(specifiers: Optional>) = + specifiers(specifiers.getOrNull()) - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.specifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.specifiers] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun specifiers(specifiers: JsonField>) = apply { + this.specifiers = specifiers.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(customFields: CustomFields) = apply { - additionalProperties = customFields.additionalProperties.toMutableMap() + /** + * Adds a single [CommitSpecifierInput] to [specifiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpecifier(specifier: CommitSpecifierInput) = apply { + specifiers = + (specifiers ?: JsonField.of(mutableListOf())).also { + checkKnown("specifiers", it).add(specifier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -25344,11 +30447,21 @@ private constructor( } /** - * Returns an immutable instance of [CustomFields]. + * Returns an immutable instance of [Commit]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CustomFields = CustomFields(additionalProperties.toImmutable()) + fun build(): Commit = + Commit( + description, + name, + priority, + productId, + (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, + (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, + (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -25363,11 +30476,18 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): CustomFields = apply { + fun validate(): Commit = apply { if (validated) { return@apply } + description() + name() + priority() + productId() + applicableProductIds() + applicableProductTags() + specifiers().ifPresent { it.forEach { it.validate() } } validated = true } @@ -25387,135 +30507,100 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (priority.asKnown().isPresent) 1 else 0) + + (if (productId.asKnown().isPresent) 1 else 0) + + (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + + (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + + (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CustomFields && + return other is Commit && + description == other.description && + name == other.name && + priority == other.priority && + productId == other.productId && + applicableProductIds == other.applicableProductIds && + applicableProductTags == other.applicableProductTags && + specifiers == other.specifiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + description, + name, + priority, + productId, + applicableProductIds, + applicableProductTags, + specifiers, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode - override fun toString() = "CustomFields{additionalProperties=$additionalProperties}" + override fun toString() = + "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" } - /** Must provide either schedule_items or recurring_schedule. */ - class Schedule + class DiscountConfiguration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val creditTypeId: JsonField, - private val doNotInvoice: JsonField, - private val recurringSchedule: JsonField, - private val scheduleItems: JsonField>, + private val cap: JsonField, + private val paymentFraction: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("credit_type_id") - @ExcludeMissing - creditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("do_not_invoice") - @ExcludeMissing - doNotInvoice: JsonField = JsonMissing.of(), - @JsonProperty("recurring_schedule") - @ExcludeMissing - recurringSchedule: JsonField = JsonMissing.of(), - @JsonProperty("schedule_items") + @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), + @JsonProperty("payment_fraction") @ExcludeMissing - scheduleItems: JsonField> = JsonMissing.of(), - ) : this( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - mutableMapOf(), - ) - - /** - * Defaults to USD (cents) if not passed. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun creditTypeId(): Optional = creditTypeId.getOptional("credit_type_id") - - /** - * This field is only applicable to commit invoice schedules. If true, this schedule - * will not generate an invoice. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun doNotInvoice(): Optional = doNotInvoice.getOptional("do_not_invoice") + paymentFraction: JsonField = JsonMissing.of(), + ) : this(cap, paymentFraction, mutableMapOf()) /** - * Enter the unit price and quantity for the charge or instead only send the amount. - * If amount is sent, the unit price is assumed to be the amount and quantity is - * inferred to be 1. + * Update the discount cap. Set to null to remove an existing cap. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun recurringSchedule(): Optional = - recurringSchedule.getOptional("recurring_schedule") + fun cap(): Optional = cap.getOptional("cap") /** - * Either provide amount or provide both unit_price and quantity. + * The fraction of the original amount that the customer pays after applying the + * discount. Set to null to remove the discount fraction. For example, 0.85 means + * the customer pays 85% of the original amount (a 15% discount). * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun scheduleItems(): Optional> = - scheduleItems.getOptional("schedule_items") - - /** - * Returns the raw JSON value of [creditTypeId]. - * - * Unlike [creditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit_type_id") - @ExcludeMissing - fun _creditTypeId(): JsonField = creditTypeId - - /** - * Returns the raw JSON value of [doNotInvoice]. - * - * Unlike [doNotInvoice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("do_not_invoice") - @ExcludeMissing - fun _doNotInvoice(): JsonField = doNotInvoice + fun paymentFraction(): Optional = + paymentFraction.getOptional("payment_fraction") /** - * Returns the raw JSON value of [recurringSchedule]. + * Returns the raw JSON value of [cap]. * - * Unlike [recurringSchedule], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [cap], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("recurring_schedule") - @ExcludeMissing - fun _recurringSchedule(): JsonField = recurringSchedule + @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap /** - * Returns the raw JSON value of [scheduleItems]. + * Returns the raw JSON value of [paymentFraction]. * - * Unlike [scheduleItems], this method doesn't throw if the JSON field has an + * Unlike [paymentFraction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("schedule_items") + @JsonProperty("payment_fraction") @ExcludeMissing - fun _scheduleItems(): JsonField> = scheduleItems + fun _paymentFraction(): JsonField = paymentFraction @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -25531,105 +30616,75 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Schedule]. */ + /** + * Returns a mutable builder for constructing an instance of + * [DiscountConfiguration]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Schedule]. */ + /** A builder for [DiscountConfiguration]. */ class Builder internal constructor() { - private var creditTypeId: JsonField = JsonMissing.of() - private var doNotInvoice: JsonField = JsonMissing.of() - private var recurringSchedule: JsonField = JsonMissing.of() - private var scheduleItems: JsonField>? = null + private var cap: JsonField = JsonMissing.of() + private var paymentFraction: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(schedule: Schedule) = apply { - creditTypeId = schedule.creditTypeId - doNotInvoice = schedule.doNotInvoice - recurringSchedule = schedule.recurringSchedule - scheduleItems = schedule.scheduleItems.map { it.toMutableList() } - additionalProperties = schedule.additionalProperties.toMutableMap() + internal fun from(discountConfiguration: DiscountConfiguration) = apply { + cap = discountConfiguration.cap + paymentFraction = discountConfiguration.paymentFraction + additionalProperties = + discountConfiguration.additionalProperties.toMutableMap() } - /** Defaults to USD (cents) if not passed. */ - fun creditTypeId(creditTypeId: String) = - creditTypeId(JsonField.of(creditTypeId)) - - /** - * Sets [Builder.creditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.creditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun creditTypeId(creditTypeId: JsonField) = apply { - this.creditTypeId = creditTypeId - } + /** Update the discount cap. Set to null to remove an existing cap. */ + fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - /** - * This field is only applicable to commit invoice schedules. If true, this - * schedule will not generate an invoice. - */ - fun doNotInvoice(doNotInvoice: Boolean) = - doNotInvoice(JsonField.of(doNotInvoice)) + /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ + fun cap(cap: Optional) = cap(cap.getOrNull()) /** - * Sets [Builder.doNotInvoice] to an arbitrary JSON value. + * Sets [Builder.cap] to an arbitrary JSON value. * - * You should usually call [Builder.doNotInvoice] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.cap] with a well-typed [Cap] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun doNotInvoice(doNotInvoice: JsonField) = apply { - this.doNotInvoice = doNotInvoice - } + fun cap(cap: JsonField) = apply { this.cap = cap } /** - * Enter the unit price and quantity for the charge or instead only send the - * amount. If amount is sent, the unit price is assumed to be the amount and - * quantity is inferred to be 1. + * The fraction of the original amount that the customer pays after applying the + * discount. Set to null to remove the discount fraction. For example, 0.85 + * means the customer pays 85% of the original amount (a 15% discount). */ - fun recurringSchedule(recurringSchedule: RecurringSchedule) = - recurringSchedule(JsonField.of(recurringSchedule)) + fun paymentFraction(paymentFraction: Double?) = + paymentFraction(JsonField.ofNullable(paymentFraction)) /** - * Sets [Builder.recurringSchedule] to an arbitrary JSON value. + * Alias for [Builder.paymentFraction]. * - * You should usually call [Builder.recurringSchedule] with a well-typed - * [RecurringSchedule] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun recurringSchedule(recurringSchedule: JsonField) = apply { - this.recurringSchedule = recurringSchedule - } - - /** Either provide amount or provide both unit_price and quantity. */ - fun scheduleItems(scheduleItems: List) = - scheduleItems(JsonField.of(scheduleItems)) + fun paymentFraction(paymentFraction: Double) = + paymentFraction(paymentFraction as Double?) /** - * Sets [Builder.scheduleItems] to an arbitrary JSON value. - * - * You should usually call [Builder.scheduleItems] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Alias for calling [Builder.paymentFraction] with + * `paymentFraction.orElse(null)`. */ - fun scheduleItems(scheduleItems: JsonField>) = apply { - this.scheduleItems = scheduleItems.map { it.toMutableList() } - } + fun paymentFraction(paymentFraction: Optional) = + paymentFraction(paymentFraction.getOrNull()) /** - * Adds a single [ScheduleItem] to [scheduleItems]. + * Sets [Builder.paymentFraction] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.paymentFraction] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addScheduleItem(scheduleItem: ScheduleItem) = apply { - scheduleItems = - (scheduleItems ?: JsonField.of(mutableListOf())).also { - checkKnown("scheduleItems", it).add(scheduleItem) - } + fun paymentFraction(paymentFraction: JsonField) = apply { + this.paymentFraction = paymentFraction } fun additionalProperties(additionalProperties: Map) = apply { @@ -25655,16 +30710,14 @@ private constructor( } /** - * Returns an immutable instance of [Schedule]. + * Returns an immutable instance of [DiscountConfiguration]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Schedule = - Schedule( - creditTypeId, - doNotInvoice, - recurringSchedule, - (scheduleItems ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): DiscountConfiguration = + DiscountConfiguration( + cap, + paymentFraction, additionalProperties.toMutableMap(), ) } @@ -25681,15 +30734,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Schedule = apply { + fun validate(): DiscountConfiguration = apply { if (validated) { return@apply } - creditTypeId() - doNotInvoice() - recurringSchedule().ifPresent { it.validate() } - scheduleItems().ifPresent { it.forEach { it.validate() } } + cap().ifPresent { it.validate() } + paymentFraction() validated = true } @@ -25709,165 +30760,46 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (creditTypeId.asKnown().isPresent) 1 else 0) + - (if (doNotInvoice.asKnown().isPresent) 1 else 0) + - (recurringSchedule.asKnown().getOrNull()?.validity() ?: 0) + - (scheduleItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (cap.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentFraction.asKnown().isPresent) 1 else 0) - /** - * Enter the unit price and quantity for the charge or instead only send the amount. - * If amount is sent, the unit price is assumed to be the amount and quantity is - * inferred to be 1. - */ - class RecurringSchedule + /** Update the discount cap. Set to null to remove an existing cap. */ + class Cap @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val amountDistribution: JsonField, - private val endingBefore: JsonField, - private val frequency: JsonField, - private val startingAt: JsonField, private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, + private val spendTrackerAlias: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount_distribution") - @ExcludeMissing - amountDistribution: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("frequency") - @ExcludeMissing - frequency: JsonField = JsonMissing.of(), - @JsonProperty("starting_at") - @ExcludeMissing - startingAt: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - mutableMapOf(), - ) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun amountDistribution(): AmountDistribution = - amountDistribution.getRequired("amount_distribution") + spendTrackerAlias: JsonField = JsonMissing.of(), + ) : this(amount, spendTrackerAlias, mutableMapOf()) /** - * RFC 3339 timestamp (exclusive). + * Accumulated spend ceiling above which the discount stops applying. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun endingBefore(): OffsetDateTime = endingBefore.getRequired("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun frequency(): Frequency = frequency.getRequired("frequency") + fun amount(): Double = amount.getRequired("amount") /** - * RFC 3339 timestamp (inclusive). + * Alias of the spend tracker this cap is measured against. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun startingAt(): OffsetDateTime = startingAt.getRequired("starting_at") - - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the - * amount and must be specified with unit_price. If specified amount cannot be - * provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") - - /** - * Unit price for the charge. Will be multiplied by quantity to determine the - * amount and must be specified with quantity. If specified amount cannot be - * provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - - /** - * Returns the raw JSON value of [amountDistribution]. - * - * Unlike [amountDistribution], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("amount_distribution") - @ExcludeMissing - fun _amountDistribution(): JsonField = amountDistribution - - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [frequency]. - * - * Unlike [frequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("frequency") - @ExcludeMissing - fun _frequency(): JsonField = frequency - - /** - * Returns the raw JSON value of [startingAt]. - * - * Unlike [startingAt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("starting_at") - @ExcludeMissing - fun _startingAt(): JsonField = startingAt + fun spendTrackerAlias(): String = + spendTrackerAlias.getRequired("spend_tracker_alias") /** * Returns the raw JSON value of [amount]. @@ -25880,24 +30812,14 @@ private constructor( fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [spendTrackerAlias]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("unit_price") + @JsonProperty("spend_tracker_alias") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun _spendTrackerAlias(): JsonField = spendTrackerAlias @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -25911,112 +30833,36 @@ private constructor( fun toBuilder() = Builder().from(this) - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [RecurringSchedule]. - * - * The following fields are required: - * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecurringSchedule]. */ - class Builder internal constructor() { - - private var amountDistribution: JsonField? = null - private var endingBefore: JsonField? = null - private var frequency: JsonField? = null - private var startingAt: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(recurringSchedule: RecurringSchedule) = apply { - amountDistribution = recurringSchedule.amountDistribution - endingBefore = recurringSchedule.endingBefore - frequency = recurringSchedule.frequency - startingAt = recurringSchedule.startingAt - amount = recurringSchedule.amount - quantity = recurringSchedule.quantity - unitPrice = recurringSchedule.unitPrice - additionalProperties = - recurringSchedule.additionalProperties.toMutableMap() - } - - fun amountDistribution(amountDistribution: AmountDistribution) = - amountDistribution(JsonField.of(amountDistribution)) - - /** - * Sets [Builder.amountDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.amountDistribution] with a well-typed - * [AmountDistribution] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun amountDistribution(amountDistribution: JsonField) = - apply { - this.amountDistribution = amountDistribution - } - - /** RFC 3339 timestamp (exclusive). */ - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) - - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } - - fun frequency(frequency: Frequency) = frequency(JsonField.of(frequency)) + companion object { /** - * Sets [Builder.frequency] to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [Cap]. * - * You should usually call [Builder.frequency] with a well-typed [Frequency] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * The following fields are required: + * ```java + * .amount() + * .spendTrackerAlias() + * ``` */ - fun frequency(frequency: JsonField) = apply { - this.frequency = frequency - } + @JvmStatic fun builder() = Builder() + } - /** RFC 3339 timestamp (inclusive). */ - fun startingAt(startingAt: OffsetDateTime) = - startingAt(JsonField.of(startingAt)) + /** A builder for [Cap]. */ + class Builder internal constructor() { - /** - * Sets [Builder.startingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startingAt] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun startingAt(startingAt: JsonField) = apply { - this.startingAt = startingAt + private var amount: JsonField? = null + private var spendTrackerAlias: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cap: Cap) = apply { + amount = cap.amount + spendTrackerAlias = cap.spendTrackerAlias + additionalProperties = cap.additionalProperties.toMutableMap() } - /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the amount - * and quantity is inferred to be 1. - */ + /** Accumulated spend ceiling above which the discount stops applying. */ fun amount(amount: Double) = amount(JsonField.of(amount)) /** @@ -26028,40 +30874,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * Quantity for the charge. Will be multiplied by unit_price to determine - * the amount and must be specified with unit_price. If specified amount - * cannot be provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } - - /** - * Unit price for the charge. Will be multiplied by quantity to determine - * the amount and must be specified with quantity. If specified amount - * cannot be provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + /** Alias of the spend tracker this cap is measured against. */ + fun spendTrackerAlias(spendTrackerAlias: String) = + spendTrackerAlias(JsonField.of(spendTrackerAlias)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.spendTrackerAlias] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice + fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { + this.spendTrackerAlias = spendTrackerAlias } fun additionalProperties(additionalProperties: Map) = @@ -26087,766 +30912,906 @@ private constructor( } /** - * Returns an immutable instance of [RecurringSchedule]. + * Returns an immutable instance of [Cap]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .amountDistribution() - * .endingBefore() - * .frequency() - * .startingAt() + * .amount() + * .spendTrackerAlias() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): RecurringSchedule = - RecurringSchedule( - checkRequired("amountDistribution", amountDistribution), - checkRequired("endingBefore", endingBefore), - checkRequired("frequency", frequency), - checkRequired("startingAt", startingAt), - amount, - quantity, - unitPrice, + fun build(): Cap = + Cap( + checkRequired("amount", amount), + checkRequired("spendTrackerAlias", spendTrackerAlias), additionalProperties.toMutableMap(), ) } - private var validated: Boolean = false + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Cap = apply { + if (validated) { + return@apply + } + + amount() + spendTrackerAlias() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a 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 (spendTrackerAlias.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cap && + amount == other.amount && + spendTrackerAlias == other.spendTrackerAlias && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, spendTrackerAlias, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DiscountConfiguration && + cap == other.cap && + paymentFraction == other.paymentFraction && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cap, paymentFraction, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" + } + + class ThresholdBalanceSpecifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val exclude: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("exclude") + @ExcludeMissing + exclude: JsonField> = JsonMissing.of() + ) : this(exclude, mutableMapOf()) + + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun exclude(): List = exclude.getRequired("exclude") + + /** + * Returns the raw JSON value of [exclude]. + * + * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude") + @ExcludeMissing + fun _exclude(): JsonField> = exclude + + @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 + * [ThresholdBalanceSpecifier]. + * + * The following fields are required: + * ```java + * .exclude() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdBalanceSpecifier]. */ + class Builder internal constructor() { + + private var exclude: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = + apply { + exclude = thresholdBalanceSpecifier.exclude.map { it.toMutableList() } + additionalProperties = + thresholdBalanceSpecifier.additionalProperties.toMutableMap() + } + + fun exclude(exclude: List) = exclude(JsonField.of(exclude)) /** - * Validates that the types of all values in this object match their expected - * types recursively. + * Sets [Builder.exclude] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * You should usually call [Builder.exclude] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exclude(exclude: JsonField>) = apply { + this.exclude = exclude.map { it.toMutableList() } + } + + /** + * Adds a single [Exclude] to [Builder.exclude]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun validate(): RecurringSchedule = apply { - if (validated) { - return@apply - } + fun addExclude(exclude: Exclude) = apply { + this.exclude = + (this.exclude ?: JsonField.of(mutableListOf())).also { + checkKnown("exclude", it).add(exclude) + } + } - amountDistribution().validate() - endingBefore() - frequency().validate() - startingAt() - amount() - quantity() - unitPrice() - validated = true + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [ThresholdBalanceSpecifier]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .exclude() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (amountDistribution.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (frequency.asKnown().getOrNull()?.validity() ?: 0) + - (if (startingAt.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - - class AmountDistribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun build(): ThresholdBalanceSpecifier = + ThresholdBalanceSpecifier( + checkRequired("exclude", exclude).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false - companion object { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdBalanceSpecifier = apply { + if (validated) { + return@apply + } - @JvmField val DIVIDED = of("DIVIDED") + exclude().forEach { it.validate() } + validated = true + } - @JvmField val DIVIDED_ROUNDED = of("DIVIDED_ROUNDED") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val EACH = of("EACH") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - @JvmStatic - fun of(value: String) = AmountDistribution(JsonField.of(value)) - } + class Exclude + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customFieldFilters: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** An enum containing [AmountDistribution]'s known values. */ - enum class Known { - DIVIDED, - DIVIDED_ROUNDED, - EACH, - } + @JsonCreator + private constructor( + @JsonProperty("custom_field_filters") + @ExcludeMissing + customFieldFilters: JsonField> = JsonMissing.of() + ) : this(customFieldFilters, mutableMapOf()) - /** - * An enum containing [AmountDistribution]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AmountDistribution] can contain an unknown value in a - * couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDED, - DIVIDED_ROUNDED, - EACH, - /** - * An enum member indicating that [AmountDistribution] was instantiated - * with an unknown value. - */ - _UNKNOWN, - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun customFieldFilters(): List = + customFieldFilters.getRequired("custom_field_filters") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDED -> Value.DIVIDED - DIVIDED_ROUNDED -> Value.DIVIDED_ROUNDED - EACH -> Value.EACH - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [customFieldFilters]. + * + * Unlike [customFieldFilters], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("custom_field_filters") + @ExcludeMissing + fun _customFieldFilters(): JsonField> = + customFieldFilters - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - DIVIDED -> Known.DIVIDED - DIVIDED_ROUNDED -> Known.DIVIDED_ROUNDED - EACH -> Known.EACH - else -> - throw MetronomeInvalidDataException( - "Unknown AmountDistribution: $value" - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) + + companion object { /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * Returns a mutable builder for constructing an instance of [Exclude]. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` */ - fun validate(): AmountDistribution = apply { - if (validated) { - return@apply - } + @JvmStatic fun builder() = Builder() + } - known() - validated = true + /** A builder for [Exclude]. */ + class Builder internal constructor() { + + private var customFieldFilters: JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(exclude: Exclude) = apply { + customFieldFilters = + exclude.customFieldFilters.map { it.toMutableList() } + additionalProperties = exclude.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun customFieldFilters(customFieldFilters: List) = + customFieldFilters(JsonField.of(customFieldFilters)) /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Sets [Builder.customFieldFilters] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.customFieldFilters] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AmountDistribution && value == other.value + fun customFieldFilters( + customFieldFilters: JsonField> + ) = apply { + this.customFieldFilters = customFieldFilters.map { it.toMutableList() } } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Frequency - @JsonCreator - private constructor(private val value: JsonField) : Enum { - /** - * Returns this class instance's raw value. + * Adds a single [CustomFieldFilter] to [customFieldFilters]. * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val QUARTERLY = of("QUARTERLY") + fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { + customFieldFilters = + (customFieldFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("customFieldFilters", it).add(customFieldFilter) + } + } - @JvmField val SEMI_ANNUAL = of("SEMI_ANNUAL") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val ANNUAL = of("ANNUAL") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmField val WEEKLY = of("WEEKLY") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmStatic fun of(value: String) = Frequency(JsonField.of(value)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** An enum containing [Frequency]'s known values. */ - enum class Known { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * An enum containing [Frequency]'s known values, as well as an [_UNKNOWN] - * member. + * Returns an immutable instance of [Exclude]. * - * An instance of [Frequency] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customFieldFilters() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - enum class Value { - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - WEEKLY, - /** - * An enum member indicating that [Frequency] was instantiated with an - * unknown value. - */ - _UNKNOWN, + fun build(): Exclude = + Exclude( + checkRequired("customFieldFilters", customFieldFilters).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 MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Exclude = apply { + if (validated) { + return@apply } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - WEEKLY -> Value.WEEKLY - else -> Value._UNKNOWN - } + customFieldFilters().forEach { it.validate() } + validated = true + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - WEEKLY -> Known.WEEKLY - else -> - throw MetronomeInvalidDataException("Unknown Frequency: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class CustomFieldFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entity: JsonField, + private val key: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity") + @ExcludeMissing + entity: JsonField = JsonMissing.of(), + @JsonProperty("key") + @ExcludeMissing + key: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(entity, key, value, mutableMapOf()) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does - * not have the expected primitive type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + fun entity(): Entity = entity.getRequired("entity") /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). */ - fun validate(): Frequency = apply { - if (validated) { - return@apply - } - - known() - validated = true - } + fun key(): String = key.getRequired("key") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): String = value.getRequired("value") /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns the raw JSON value of [entity]. * - * Used for best match union deserialization. + * Unlike [entity], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Frequency && value == other.value - } + @JsonProperty("entity") + @ExcludeMissing + fun _entity(): JsonField = entity - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is RecurringSchedule && - amountDistribution == other.amountDistribution && - endingBefore == other.endingBefore && - frequency == other.frequency && - startingAt == other.startingAt && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amountDistribution, - endingBefore, - frequency, - startingAt, - amount, - quantity, - unitPrice, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RecurringSchedule{amountDistribution=$amountDistribution, endingBefore=$endingBefore, frequency=$frequency, startingAt=$startingAt, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } - - class ScheduleItem - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val timestamp: JsonField, - private val amount: JsonField, - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("timestamp") - @ExcludeMissing - timestamp: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonAnyGetter @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(timestamp, amount, quantity, unitPrice, mutableMapOf()) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * timestamp of the scheduled event - * - * @throws MetronomeInvalidDataException if 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") + fun toBuilder() = Builder().from(this) - /** - * Amount for the charge. Can be provided instead of unit_price and quantity. If - * amount is sent, the unit_price is assumed to be the amount and quantity is - * inferred to be 1. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + companion object { - /** - * Quantity for the charge. Will be multiplied by unit_price to determine the - * amount and must be specified with unit_price. If specified amount cannot be - * provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + /** + * Returns a mutable builder for constructing an instance of + * [CustomFieldFilter]. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Unit price for the charge. Will be multiplied by quantity to determine the - * amount and must be specified with quantity. If specified amount cannot be - * provided. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + /** A builder for [CustomFieldFilter]. */ + class Builder internal constructor() { - /** - * 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 + private var entity: JsonField? = null + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * 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 + @JvmSynthetic + internal fun from(customFieldFilter: CustomFieldFilter) = apply { + entity = customFieldFilter.entity + key = customFieldFilter.key + value = customFieldFilter.value + additionalProperties = + customFieldFilter.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + fun entity(entity: Entity) = entity(JsonField.of(entity)) - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + /** + * Sets [Builder.entity] to an arbitrary JSON value. + * + * You should usually call [Builder.entity] with a well-typed [Entity] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun entity(entity: JsonField) = apply { this.entity = entity } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun key(key: String) = key(JsonField.of(key)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } - fun toBuilder() = Builder().from(this) + fun value(value: String) = value(JsonField.of(value)) - companion object { + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } - /** - * Returns a mutable builder for constructing an instance of [ScheduleItem]. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** A builder for [ScheduleItem]. */ - class Builder internal constructor() { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var timestamp: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmSynthetic - internal fun from(scheduleItem: ScheduleItem) = apply { - timestamp = scheduleItem.timestamp - amount = scheduleItem.amount - quantity = scheduleItem.quantity - unitPrice = scheduleItem.unitPrice - additionalProperties = scheduleItem.additionalProperties.toMutableMap() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomFieldFilter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .entity() + * .key() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomFieldFilter = + CustomFieldFilter( + checkRequired("entity", entity), + checkRequired("key", key), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) } - /** timestamp of the scheduled event */ - fun timestamp(timestamp: OffsetDateTime) = - timestamp(JsonField.of(timestamp)) + private var validated: Boolean = false /** - * Sets [Builder.timestamp] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.timestamp] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - fun timestamp(timestamp: JsonField) = apply { - this.timestamp = timestamp + fun validate(): CustomFieldFilter = apply { + if (validated) { + return@apply + } + + entity().validate() + key() + value() + validated = true } - /** - * Amount for the charge. Can be provided instead of unit_price and - * quantity. If amount is sent, the unit_price is assumed to be the amount - * and quantity is inferred to be 1. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Sets [Builder.amount] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * 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. + * Used for best match union deserialization. */ - fun amount(amount: JsonField) = apply { this.amount = amount } + @JvmSynthetic + internal fun validity(): Int = + (entity.asKnown().getOrNull()?.validity() ?: 0) + + (if (key.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Entity + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val COMMIT = of("Commit") + + @JvmField val CONTRACT_CREDIT = of("ContractCredit") + + @JvmField + val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + + @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) + } + + /** An enum containing [Entity]'s known values. */ + enum class Known { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + } + + /** + * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Entity] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMIT, + CONTRACT_CREDIT, + CONTRACT_CREDIT_OR_COMMIT, + /** + * An enum member indicating that [Entity] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMIT -> Value.COMMIT + CONTRACT_CREDIT -> Value.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + COMMIT -> Known.COMMIT + CONTRACT_CREDIT -> Known.CONTRACT_CREDIT + CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT + else -> + throw MetronomeInvalidDataException( + "Unknown Entity: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - /** - * Quantity for the charge. Will be multiplied by unit_price to determine - * the amount and must be specified with unit_price. If specified amount - * cannot be provided. - */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + private var validated: Boolean = false - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { - this.quantity = quantity - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API + * for existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this + * object doesn't match its expected type. + */ + fun validate(): Entity = apply { + if (validated) { + return@apply + } - /** - * Unit price for the charge. Will be multiplied by quantity to determine - * the amount and must be specified with quantity. If specified amount - * cannot be provided. - */ - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + known() + validated = true + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + return other is Entity && value == other.value + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun hashCode() = value.hashCode() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun toString() = value.toString() } - /** - * Returns an immutable instance of [ScheduleItem]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .timestamp() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScheduleItem = - ScheduleItem( - checkRequired("timestamp", timestamp), - amount, - quantity, - unitPrice, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected - * types recursively. - * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): ScheduleItem = apply { - if (validated) { - return@apply + return other is CustomFieldFilter && + entity == other.entity && + key == other.key && + value == other.value && + additionalProperties == other.additionalProperties } - timestamp() - amount() - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(entity, key, value, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScheduleItem && - timestamp == other.timestamp && - amount == other.amount && - quantity == other.quantity && - unitPrice == other.unitPrice && + return other is Exclude && + customFieldFilters == other.customFieldFilters && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(timestamp, amount, quantity, unitPrice, additionalProperties) + Objects.hash(customFieldFilters, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ScheduleItem{timestamp=$timestamp, amount=$amount, quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -26854,28 +31819,17 @@ private constructor( return true } - return other is Schedule && - creditTypeId == other.creditTypeId && - doNotInvoice == other.doNotInvoice && - recurringSchedule == other.recurringSchedule && - scheduleItems == other.scheduleItems && + return other is ThresholdBalanceSpecifier && + exclude == other.exclude && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - creditTypeId, - doNotInvoice, - recurringSchedule, - scheduleItems, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(exclude, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Schedule{creditTypeId=$creditTypeId, doNotInvoice=$doNotInvoice, recurringSchedule=$recurringSchedule, scheduleItems=$scheduleItems, additionalProperties=$additionalProperties}" + "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -26883,22 +31837,28 @@ private constructor( return true } - return other is UpdateDiscount && - id == other.id && - customFields == other.customFields && - name == other.name && - netsuiteSalesOrderId == other.netsuiteSalesOrderId && - schedule == other.schedule && + return other is UpdatePrepaidBalanceThresholdConfiguration && + commit == other.commit && + customCreditTypeId == other.customCreditTypeId && + discountConfiguration == other.discountConfiguration && + isEnabled == other.isEnabled && + paymentGateConfig == other.paymentGateConfig && + rechargeToAmount == other.rechargeToAmount && + thresholdAmount == other.thresholdAmount && + thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - customFields, - name, - netsuiteSalesOrderId, - schedule, + commit, + customCreditTypeId, + discountConfiguration, + isEnabled, + paymentGateConfig, + rechargeToAmount, + thresholdAmount, + thresholdBalanceSpecifiers, additionalProperties, ) } @@ -26906,204 +31866,146 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateDiscount{id=$id, customFields=$customFields, name=$name, netsuiteSalesOrderId=$netsuiteSalesOrderId, schedule=$schedule, additionalProperties=$additionalProperties}" + "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" } - class UpdatePrepaidBalanceThresholdConfiguration + class UpdateRecurringCommit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val commit: JsonField, - private val customCreditTypeId: JsonField, - private val discountConfiguration: JsonField, - private val isEnabled: JsonField, - private val paymentGateConfig: JsonField, - private val rechargeToAmount: JsonField, - private val thresholdAmount: JsonField, - private val thresholdBalanceSpecifiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("commit") - @ExcludeMissing - commit: JsonField = JsonMissing.of(), - @JsonProperty("custom_credit_type_id") - @ExcludeMissing - customCreditTypeId: JsonField = JsonMissing.of(), - @JsonProperty("discount_configuration") - @ExcludeMissing - discountConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("is_enabled") + private val id: JsonField, + private val accessAmount: JsonField, + private val endingBefore: JsonField, + private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, + private val rateType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("access_amount") @ExcludeMissing - isEnabled: JsonField = JsonMissing.of(), - @JsonProperty("payment_gate_config") + accessAmount: JsonField = JsonMissing.of(), + @JsonProperty("ending_before") @ExcludeMissing - paymentGateConfig: JsonField = JsonMissing.of(), - @JsonProperty("recharge_to_amount") + endingBefore: JsonField = JsonMissing.of(), + @JsonProperty("invoice_amount") @ExcludeMissing - rechargeToAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_amount") + invoiceAmount: JsonField = JsonMissing.of(), + @JsonProperty("proration_rounding") @ExcludeMissing - thresholdAmount: JsonField = JsonMissing.of(), - @JsonProperty("threshold_balance_specifiers") + prorationRounding: JsonField = JsonMissing.of(), + @JsonProperty("rate_type") @ExcludeMissing - thresholdBalanceSpecifiers: JsonField> = - JsonMissing.of(), + rateType: JsonField = JsonMissing.of(), ) : this( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + id, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, mutableMapOf(), ) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun commit(): Optional = commit.getOptional("commit") - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold commit - * amount will be in terms of this credit type instead of the fiat currency. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customCreditTypeId(): Optional = - customCreditTypeId.getOptional("custom_credit_type_id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun discountConfiguration(): Optional = - discountConfiguration.getOptional("discount_configuration") + fun id(): String = id.getRequired("id") /** - * When set to false, the contract will not be evaluated against the threshold_amount. - * Toggling to true will result an immediate evaluation, regardless of prior state. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun isEnabled(): Optional = isEnabled.getOptional("is_enabled") + fun accessAmount(): Optional = accessAmount.getOptional("access_amount") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun paymentGateConfig(): Optional = - paymentGateConfig.getOptional("payment_gate_config") + fun endingBefore(): Optional = endingBefore.getOptional("ending_before") /** - * Specify the amount the balance should be recharged to. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun rechargeToAmount(): Optional = - rechargeToAmount.getOptional("recharge_to_amount") + fun invoiceAmount(): Optional = + invoiceAmount.getOptional("invoice_amount") /** - * Specify the threshold amount for the contract. Each time the contract's balance - * lowers to this amount, a threshold charge will be initiated. + * Rounding configuration for prorated recurring commit amounts. * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun thresholdAmount(): Optional = - thresholdAmount.getOptional("threshold_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun thresholdBalanceSpecifiers(): Optional> = - thresholdBalanceSpecifiers.getOptional("threshold_balance_specifiers") - - /** - * Returns the raw JSON value of [commit]. - * - * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - - /** - * Returns the raw JSON value of [customCreditTypeId]. - * - * Unlike [customCreditTypeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("custom_credit_type_id") - @ExcludeMissing - fun _customCreditTypeId(): JsonField = customCreditTypeId + fun rateType(): Optional = rateType.getOptional("rate_type") /** - * Returns the raw JSON value of [discountConfiguration]. + * Returns the raw JSON value of [id]. * - * Unlike [discountConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("discount_configuration") - @ExcludeMissing - fun _discountConfiguration(): JsonField = discountConfiguration + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [isEnabled]. + * Returns the raw JSON value of [accessAmount]. * - * Unlike [isEnabled], this method doesn't throw if the JSON field has an unexpected + * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("is_enabled") + @JsonProperty("access_amount") @ExcludeMissing - fun _isEnabled(): JsonField = isEnabled + fun _accessAmount(): JsonField = accessAmount /** - * Returns the raw JSON value of [paymentGateConfig]. + * Returns the raw JSON value of [endingBefore]. * - * Unlike [paymentGateConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("payment_gate_config") + @JsonProperty("ending_before") @ExcludeMissing - fun _paymentGateConfig(): JsonField = paymentGateConfig + fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [rechargeToAmount]. + * Returns the raw JSON value of [invoiceAmount]. * - * Unlike [rechargeToAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("recharge_to_amount") + @JsonProperty("invoice_amount") @ExcludeMissing - fun _rechargeToAmount(): JsonField = rechargeToAmount + fun _invoiceAmount(): JsonField = invoiceAmount /** - * Returns the raw JSON value of [thresholdAmount]. + * Returns the raw JSON value of [prorationRounding]. * - * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("threshold_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _thresholdAmount(): JsonField = thresholdAmount + fun _prorationRounding(): JsonField = prorationRounding /** - * Returns the raw JSON value of [thresholdBalanceSpecifiers]. + * Returns the raw JSON value of [rateType]. * - * Unlike [thresholdBalanceSpecifiers], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("threshold_balance_specifiers") + @JsonProperty("rate_type") @ExcludeMissing - fun _thresholdBalanceSpecifiers(): JsonField> = - thresholdBalanceSpecifiers + fun _rateType(): JsonField = rateType @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27121,211 +32023,123 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UpdatePrepaidBalanceThresholdConfiguration]. + * [UpdateRecurringCommit]. + * + * The following fields are required: + * ```java + * .id() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UpdatePrepaidBalanceThresholdConfiguration]. */ + /** A builder for [UpdateRecurringCommit]. */ class Builder internal constructor() { - private var commit: JsonField = JsonMissing.of() - private var customCreditTypeId: JsonField = JsonMissing.of() - private var discountConfiguration: JsonField = - JsonMissing.of() - private var isEnabled: JsonField = JsonMissing.of() - private var paymentGateConfig: JsonField = JsonMissing.of() - private var rechargeToAmount: JsonField = JsonMissing.of() - private var thresholdAmount: JsonField = JsonMissing.of() - private var thresholdBalanceSpecifiers: - JsonField>? = - null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - updatePrepaidBalanceThresholdConfiguration: - UpdatePrepaidBalanceThresholdConfiguration - ) = apply { - commit = updatePrepaidBalanceThresholdConfiguration.commit - customCreditTypeId = - updatePrepaidBalanceThresholdConfiguration.customCreditTypeId - discountConfiguration = - updatePrepaidBalanceThresholdConfiguration.discountConfiguration - isEnabled = updatePrepaidBalanceThresholdConfiguration.isEnabled - paymentGateConfig = updatePrepaidBalanceThresholdConfiguration.paymentGateConfig - rechargeToAmount = updatePrepaidBalanceThresholdConfiguration.rechargeToAmount - thresholdAmount = updatePrepaidBalanceThresholdConfiguration.thresholdAmount - thresholdBalanceSpecifiers = - updatePrepaidBalanceThresholdConfiguration.thresholdBalanceSpecifiers.map { - it.toMutableList() - } - additionalProperties = - updatePrepaidBalanceThresholdConfiguration.additionalProperties - .toMutableMap() - } - - fun commit(commit: Commit) = commit(JsonField.of(commit)) - - /** - * Sets [Builder.commit] to an arbitrary JSON value. - * - * You should usually call [Builder.commit] with a well-typed [Commit] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun commit(commit: JsonField) = apply { this.commit = commit } - - /** - * If provided, the threshold, recharge-to amount, and the resulting threshold - * commit amount will be in terms of this credit type instead of the fiat currency. - */ - fun customCreditTypeId(customCreditTypeId: String?) = - customCreditTypeId(JsonField.ofNullable(customCreditTypeId)) - - /** - * Alias for calling [Builder.customCreditTypeId] with - * `customCreditTypeId.orElse(null)`. - */ - fun customCreditTypeId(customCreditTypeId: Optional) = - customCreditTypeId(customCreditTypeId.getOrNull()) - - /** - * Sets [Builder.customCreditTypeId] to an arbitrary JSON value. - * - * You should usually call [Builder.customCreditTypeId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customCreditTypeId(customCreditTypeId: JsonField) = apply { - this.customCreditTypeId = customCreditTypeId - } - - fun discountConfiguration(discountConfiguration: DiscountConfiguration?) = - discountConfiguration(JsonField.ofNullable(discountConfiguration)) - - /** - * Alias for calling [Builder.discountConfiguration] with - * `discountConfiguration.orElse(null)`. - */ - fun discountConfiguration(discountConfiguration: Optional) = - discountConfiguration(discountConfiguration.getOrNull()) - - /** - * Sets [Builder.discountConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.discountConfiguration] with a well-typed - * [DiscountConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun discountConfiguration(discountConfiguration: JsonField) = - apply { - this.discountConfiguration = discountConfiguration - } + private var id: JsonField? = null + private var accessAmount: JsonField = JsonMissing.of() + private var endingBefore: JsonField = JsonMissing.of() + private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() + private var rateType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * When set to false, the contract will not be evaluated against the - * threshold_amount. Toggling to true will result an immediate evaluation, - * regardless of prior state. - */ - fun isEnabled(isEnabled: Boolean) = isEnabled(JsonField.of(isEnabled)) + @JvmSynthetic + internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { + id = updateRecurringCommit.id + accessAmount = updateRecurringCommit.accessAmount + endingBefore = updateRecurringCommit.endingBefore + invoiceAmount = updateRecurringCommit.invoiceAmount + prorationRounding = updateRecurringCommit.prorationRounding + rateType = updateRecurringCommit.rateType + additionalProperties = updateRecurringCommit.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.isEnabled] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.isEnabled] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun isEnabled(isEnabled: JsonField) = apply { this.isEnabled = isEnabled } + fun id(id: JsonField) = apply { this.id = id } - fun paymentGateConfig(paymentGateConfig: PaymentGateConfigV2) = - paymentGateConfig(JsonField.of(paymentGateConfig)) + fun accessAmount(accessAmount: AccessAmount) = + accessAmount(JsonField.of(accessAmount)) /** - * Sets [Builder.paymentGateConfig] to an arbitrary JSON value. + * Sets [Builder.accessAmount] to an arbitrary JSON value. * - * You should usually call [Builder.paymentGateConfig] with a well-typed - * [PaymentGateConfigV2] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun paymentGateConfig(paymentGateConfig: JsonField) = apply { - this.paymentGateConfig = paymentGateConfig + fun accessAmount(accessAmount: JsonField) = apply { + this.accessAmount = accessAmount } - /** Specify the amount the balance should be recharged to. */ - fun rechargeToAmount(rechargeToAmount: Double) = - rechargeToAmount(JsonField.of(rechargeToAmount)) + fun endingBefore(endingBefore: OffsetDateTime) = + endingBefore(JsonField.of(endingBefore)) /** - * Sets [Builder.rechargeToAmount] to an arbitrary JSON value. + * Sets [Builder.endingBefore] to an arbitrary JSON value. * - * You should usually call [Builder.rechargeToAmount] with a well-typed [Double] + * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun rechargeToAmount(rechargeToAmount: JsonField) = apply { - this.rechargeToAmount = rechargeToAmount + fun endingBefore(endingBefore: JsonField) = apply { + this.endingBefore = endingBefore } - /** - * Specify the threshold amount for the contract. Each time the contract's balance - * lowers to this amount, a threshold charge will be initiated. - */ - fun thresholdAmount(thresholdAmount: Double) = - thresholdAmount(JsonField.of(thresholdAmount)) + fun invoiceAmount(invoiceAmount: InvoiceAmount) = + invoiceAmount(JsonField.of(invoiceAmount)) /** - * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * Sets [Builder.invoiceAmount] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdAmount] with a well-typed [Double] + * You should usually call [Builder.invoiceAmount] with a well-typed [InvoiceAmount] * value instead. This method is primarily for setting the field to an undocumented * or not yet supported value. */ - fun thresholdAmount(thresholdAmount: JsonField) = apply { - this.thresholdAmount = thresholdAmount + fun invoiceAmount(invoiceAmount: JsonField) = apply { + this.invoiceAmount = invoiceAmount } - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: List? - ) = thresholdBalanceSpecifiers(JsonField.ofNullable(thresholdBalanceSpecifiers)) + /** Rounding configuration for prorated recurring commit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Alias for calling [Builder.thresholdBalanceSpecifiers] with - * `thresholdBalanceSpecifiers.orElse(null)`. + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: Optional> - ) = thresholdBalanceSpecifiers(thresholdBalanceSpecifiers.getOrNull()) + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) /** - * Sets [Builder.thresholdBalanceSpecifiers] to an arbitrary JSON value. + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.thresholdBalanceSpecifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun thresholdBalanceSpecifiers( - thresholdBalanceSpecifiers: JsonField> - ) = apply { - this.thresholdBalanceSpecifiers = - thresholdBalanceSpecifiers.map { it.toMutableList() } + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } + fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + /** - * Adds a single [ThresholdBalanceSpecifier] to [thresholdBalanceSpecifiers]. + * Sets [Builder.rateType] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.rateType] with a well-typed [RateType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun addThresholdBalanceSpecifier( - thresholdBalanceSpecifier: ThresholdBalanceSpecifier - ) = apply { - thresholdBalanceSpecifiers = - (thresholdBalanceSpecifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("thresholdBalanceSpecifiers", it) - .add(thresholdBalanceSpecifier) - } - } + fun rateType(rateType: JsonField) = apply { this.rateType = rateType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -27350,20 +32164,25 @@ private constructor( } /** - * Returns an immutable instance of [UpdatePrepaidBalanceThresholdConfiguration]. + * Returns an immutable instance of [UpdateRecurringCommit]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdatePrepaidBalanceThresholdConfiguration = - UpdatePrepaidBalanceThresholdConfiguration( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - (thresholdBalanceSpecifiers ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): UpdateRecurringCommit = + UpdateRecurringCommit( + checkRequired("id", id), + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties.toMutableMap(), ) } @@ -27380,19 +32199,17 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): UpdatePrepaidBalanceThresholdConfiguration = apply { + fun validate(): UpdateRecurringCommit = apply { if (validated) { return@apply } - commit().ifPresent { it.validate() } - customCreditTypeId() - discountConfiguration().ifPresent { it.validate() } - isEnabled() - paymentGateConfig().ifPresent { it.validate() } - rechargeToAmount() - thresholdAmount() - thresholdBalanceSpecifiers().ifPresent { it.forEach { it.validate() } } + id() + accessAmount().ifPresent { it.validate() } + endingBefore() + invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } + rateType().ifPresent { it.validate() } validated = true } @@ -27412,207 +32229,62 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (commit.asKnown().getOrNull()?.validity() ?: 0) + - (if (customCreditTypeId.asKnown().isPresent) 1 else 0) + - (discountConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (isEnabled.asKnown().isPresent) 1 else 0) + - (paymentGateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (rechargeToAmount.asKnown().isPresent) 1 else 0) + - (if (thresholdAmount.asKnown().isPresent) 1 else 0) + - (thresholdBalanceSpecifiers.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) - - class Commit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val description: JsonField, - private val name: JsonField, - private val priority: JsonField, - private val productId: JsonField, - private val applicableProductIds: JsonField>, - private val applicableProductTags: JsonField>, - private val specifiers: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("product_id") - @ExcludeMissing - productId: JsonField = JsonMissing.of(), - @JsonProperty("applicable_product_ids") - @ExcludeMissing - applicableProductIds: JsonField> = JsonMissing.of(), - @JsonProperty("applicable_product_tags") - @ExcludeMissing - applicableProductTags: JsonField> = JsonMissing.of(), - @JsonProperty("specifiers") - @ExcludeMissing - specifiers: JsonField> = JsonMissing.of(), - ) : this( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - mutableMapOf(), - ) - - fun toUpdateBaseThresholdCommit(): UpdateBaseThresholdCommit = - UpdateBaseThresholdCommit.builder() - .description(description) - .name(name) - .priority(priority) - .productId(productId) - .build() - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Specify the name of the line item for the threshold charge. If left blank, it - * will default to the commit product name. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The priority of the commit, used to determine drawdown order. Lower priority - * commits are consumed first. Defaults to 100 if not specified. On updates, set to - * null to clear a previously configured priority. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun priority(): Optional = priority.getOptional("priority") - - /** - * The commit product that will be used to generate the line item for commit - * payment. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun productId(): Optional = productId.getOptional("product_id") + (if (id.asKnown().isPresent) 1 else 0) + + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBefore.asKnown().isPresent) 1 else 0) + + (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + + (rateType.asKnown().getOrNull()?.validity() ?: 0) - /** - * Which products the threshold commit applies to. If both applicable_product_ids - * and applicable_product_tags are not provided, the commit applies to all products. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun applicableProductIds(): Optional> = - applicableProductIds.getOptional("applicable_product_ids") + class AccessAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val quantity: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) /** - * Which tags the threshold commit applies to. If both applicable_product_ids and - * applicable_product_tags are not provided, the commit applies to all products. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun applicableProductTags(): Optional> = - applicableProductTags.getOptional("applicable_product_tags") + fun quantity(): Optional = quantity.getOptional("quantity") /** - * List of filters that determine what kind of customer usage draws down a commit or - * credit. A customer's usage needs to meet the condition of at least one of the - * specifiers to contribute to a commit's or credit's drawdown. This field cannot be - * used together with `applicable_product_ids` or `applicable_product_tags`. - * Instead, to target usage by product or product tag, pass those values in the body - * of `specifiers`. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun specifiers(): Optional> = - specifiers.getOptional("specifiers") - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") /** - * Returns the raw JSON value of [priority]. + * Returns the raw JSON value of [quantity]. * - * Unlike [priority], this method doesn't throw if the JSON field has an unexpected + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("priority") + @JsonProperty("quantity") @ExcludeMissing - fun _priority(): JsonField = priority + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [productId]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [productId], this method doesn't throw if the JSON field has an unexpected + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("product_id") - @ExcludeMissing - fun _productId(): JsonField = productId - - /** - * Returns the raw JSON value of [applicableProductIds]. - * - * Unlike [applicableProductIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("applicable_product_ids") - @ExcludeMissing - fun _applicableProductIds(): JsonField> = applicableProductIds - - /** - * Returns the raw JSON value of [applicableProductTags]. - * - * Unlike [applicableProductTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("applicable_product_tags") - @ExcludeMissing - fun _applicableProductTags(): JsonField> = applicableProductTags - - /** - * Returns the raw JSON value of [specifiers]. - * - * Unlike [specifiers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("specifiers") + @JsonProperty("unit_price") @ExcludeMissing - fun _specifiers(): JsonField> = specifiers + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -27628,223 +32300,46 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Commit]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Commit]. */ - class Builder internal constructor() { - - private var description: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var productId: JsonField = JsonMissing.of() - private var applicableProductIds: JsonField>? = null - private var applicableProductTags: JsonField>? = null - private var specifiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commit: Commit) = apply { - description = commit.description - name = commit.name - priority = commit.priority - productId = commit.productId - applicableProductIds = - commit.applicableProductIds.map { it.toMutableList() } - applicableProductTags = - commit.applicableProductTags.map { it.toMutableList() } - specifiers = commit.specifiers.map { it.toMutableList() } - additionalProperties = commit.additionalProperties.toMutableMap() - } - - fun description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * Specify the name of the line item for the threshold charge. If left blank, it - * will default to the commit product name. - */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The priority of the commit, used to determine drawdown order. Lower priority - * commits are consumed first. Defaults to 100 if not specified. On updates, set - * to null to clear a previously configured priority. - */ - fun priority(priority: Double?) = priority(JsonField.ofNullable(priority)) - - /** - * Alias for [Builder.priority]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun priority(priority: Double) = priority(priority as Double?) - - /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ - fun priority(priority: Optional) = priority(priority.getOrNull()) - - /** - * Sets [Builder.priority] to an arbitrary JSON value. - * - * You should usually call [Builder.priority] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun priority(priority: JsonField) = apply { this.priority = priority } - - /** - * The commit product that will be used to generate the line item for commit - * payment. - */ - fun productId(productId: String) = productId(JsonField.of(productId)) - - /** - * Sets [Builder.productId] to an arbitrary JSON value. - * - * You should usually call [Builder.productId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productId(productId: JsonField) = apply { - this.productId = productId - } - - /** - * Which products the threshold commit applies to. If both - * applicable_product_ids and applicable_product_tags are not provided, the - * commit applies to all products. - */ - fun applicableProductIds(applicableProductIds: List?) = - applicableProductIds(JsonField.ofNullable(applicableProductIds)) - - /** - * Alias for calling [Builder.applicableProductIds] with - * `applicableProductIds.orElse(null)`. - */ - fun applicableProductIds(applicableProductIds: Optional>) = - applicableProductIds(applicableProductIds.getOrNull()) - - /** - * Sets [Builder.applicableProductIds] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductIds] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun applicableProductIds(applicableProductIds: JsonField>) = - apply { - this.applicableProductIds = - applicableProductIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [applicableProductIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductId(applicableProductId: String) = apply { - applicableProductIds = - (applicableProductIds ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductIds", it).add(applicableProductId) - } - } - - /** - * Which tags the threshold commit applies to. If both applicable_product_ids - * and applicable_product_tags are not provided, the commit applies to all - * products. - */ - fun applicableProductTags(applicableProductTags: List?) = - applicableProductTags(JsonField.ofNullable(applicableProductTags)) - - /** - * Alias for calling [Builder.applicableProductTags] with - * `applicableProductTags.orElse(null)`. - */ - fun applicableProductTags(applicableProductTags: Optional>) = - applicableProductTags(applicableProductTags.getOrNull()) + /** Returns a mutable builder for constructing an instance of [AccessAmount]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.applicableProductTags] to an arbitrary JSON value. - * - * You should usually call [Builder.applicableProductTags] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun applicableProductTags(applicableProductTags: JsonField>) = - apply { - this.applicableProductTags = - applicableProductTags.map { it.toMutableList() } - } + /** A builder for [AccessAmount]. */ + class Builder internal constructor() { - /** - * Adds a single [String] to [applicableProductTags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addApplicableProductTag(applicableProductTag: String) = apply { - applicableProductTags = - (applicableProductTags ?: JsonField.of(mutableListOf())).also { - checkKnown("applicableProductTags", it).add(applicableProductTag) - } - } + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * List of filters that determine what kind of customer usage draws down a - * commit or credit. A customer's usage needs to meet the condition of at least - * one of the specifiers to contribute to a commit's or credit's drawdown. This - * field cannot be used together with `applicable_product_ids` or - * `applicable_product_tags`. Instead, to target usage by product or product - * tag, pass those values in the body of `specifiers`. - */ - fun specifiers(specifiers: List?) = - specifiers(JsonField.ofNullable(specifiers)) + @JvmSynthetic + internal fun from(accessAmount: AccessAmount) = apply { + quantity = accessAmount.quantity + unitPrice = accessAmount.unitPrice + additionalProperties = accessAmount.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.specifiers] with `specifiers.orElse(null)`. */ - fun specifiers(specifiers: Optional>) = - specifiers(specifiers.getOrNull()) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Sets [Builder.specifiers] to an arbitrary JSON value. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * You should usually call [Builder.specifiers] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun specifiers(specifiers: JsonField>) = apply { - this.specifiers = specifiers.map { it.toMutableList() } - } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Adds a single [CommitSpecifierInput] to [specifiers]. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addSpecifier(specifier: CommitSpecifierInput) = apply { - specifiers = - (specifiers ?: JsonField.of(mutableListOf())).also { - checkKnown("specifiers", it).add(specifier) - } + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = apply { @@ -27870,21 +32365,12 @@ private constructor( } /** - * Returns an immutable instance of [Commit]. + * Returns an immutable instance of [AccessAmount]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Commit = - Commit( - description, - name, - priority, - productId, - (applicableProductIds ?: JsonMissing.of()).map { it.toImmutable() }, - (applicableProductTags ?: JsonMissing.of()).map { it.toImmutable() }, - (specifiers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): AccessAmount = + AccessAmount(quantity, unitPrice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -27899,18 +32385,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): Commit = apply { + fun validate(): AccessAmount = apply { if (validated) { return@apply } - description() - name() - priority() - productId() - applicableProductIds() - applicableProductTags() - specifiers().ifPresent { it.forEach { it.validate() } } + quantity() + unitPrice() validated = true } @@ -27930,100 +32411,79 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (description.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (priority.asKnown().isPresent) 1 else 0) + - (if (productId.asKnown().isPresent) 1 else 0) + - (applicableProductIds.asKnown().getOrNull()?.size ?: 0) + - (applicableProductTags.asKnown().getOrNull()?.size ?: 0) + - (specifiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Commit && - description == other.description && - name == other.name && - priority == other.priority && - productId == other.productId && - applicableProductIds == other.applicableProductIds && - applicableProductTags == other.applicableProductTags && - specifiers == other.specifiers && + return other is AccessAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - description, - name, - priority, - productId, - applicableProductIds, - applicableProductTags, - specifiers, - additionalProperties, - ) + Objects.hash(quantity, unitPrice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Commit{description=$description, name=$name, priority=$priority, productId=$productId, applicableProductIds=$applicableProductIds, applicableProductTags=$applicableProductTags, specifiers=$specifiers, additionalProperties=$additionalProperties}" + "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class DiscountConfiguration + class InvoiceAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cap: JsonField, - private val paymentFraction: JsonField, + private val quantity: JsonField, + private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cap") @ExcludeMissing cap: JsonField = JsonMissing.of(), - @JsonProperty("payment_fraction") + @JsonProperty("quantity") @ExcludeMissing - paymentFraction: JsonField = JsonMissing.of(), - ) : this(cap, paymentFraction, mutableMapOf()) + quantity: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this(quantity, unitPrice, mutableMapOf()) /** - * Update the discount cap. Set to null to remove an existing cap. - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun cap(): Optional = cap.getOptional("cap") + fun quantity(): Optional = quantity.getOptional("quantity") /** - * The fraction of the original amount that the customer pays after applying the - * discount. Set to null to remove the discount fraction. For example, 0.85 means - * the customer pays 85% of the original amount (a 15% discount). - * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun paymentFraction(): Optional = - paymentFraction.getOptional("payment_fraction") + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") /** - * Returns the raw JSON value of [cap]. + * Returns the raw JSON value of [quantity]. * - * Unlike [cap], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("cap") @ExcludeMissing fun _cap(): JsonField = cap + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity /** - * Returns the raw JSON value of [paymentFraction]. + * Returns the raw JSON value of [unitPrice]. * - * Unlike [paymentFraction], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("payment_fraction") + @JsonProperty("unit_price") @ExcludeMissing - fun _paymentFraction(): JsonField = paymentFraction + fun _unitPrice(): JsonField = unitPrice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28040,74 +32500,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DiscountConfiguration]. + * Returns a mutable builder for constructing an instance of [InvoiceAmount]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DiscountConfiguration]. */ + /** A builder for [InvoiceAmount]. */ class Builder internal constructor() { - private var cap: JsonField = JsonMissing.of() - private var paymentFraction: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(discountConfiguration: DiscountConfiguration) = apply { - cap = discountConfiguration.cap - paymentFraction = discountConfiguration.paymentFraction - additionalProperties = - discountConfiguration.additionalProperties.toMutableMap() + internal fun from(invoiceAmount: InvoiceAmount) = apply { + quantity = invoiceAmount.quantity + unitPrice = invoiceAmount.unitPrice + additionalProperties = invoiceAmount.additionalProperties.toMutableMap() } - /** Update the discount cap. Set to null to remove an existing cap. */ - fun cap(cap: Cap?) = cap(JsonField.ofNullable(cap)) - - /** Alias for calling [Builder.cap] with `cap.orElse(null)`. */ - fun cap(cap: Optional) = cap(cap.getOrNull()) - - /** - * Sets [Builder.cap] to an arbitrary JSON value. - * - * You should usually call [Builder.cap] with a well-typed [Cap] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cap(cap: JsonField) = apply { this.cap = cap } - - /** - * The fraction of the original amount that the customer pays after applying the - * discount. Set to null to remove the discount fraction. For example, 0.85 - * means the customer pays 85% of the original amount (a 15% discount). - */ - fun paymentFraction(paymentFraction: Double?) = - paymentFraction(JsonField.ofNullable(paymentFraction)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** - * Alias for [Builder.paymentFraction]. + * Sets [Builder.quantity] to an arbitrary JSON value. * - * This unboxed primitive overload exists for backwards compatibility. + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun paymentFraction(paymentFraction: Double) = - paymentFraction(paymentFraction as Double?) + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** - * Alias for calling [Builder.paymentFraction] with - * `paymentFraction.orElse(null)`. - */ - fun paymentFraction(paymentFraction: Optional) = - paymentFraction(paymentFraction.getOrNull()) + fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) /** - * Sets [Builder.paymentFraction] to an arbitrary JSON value. + * Sets [Builder.unitPrice] to an arbitrary JSON value. * - * You should usually call [Builder.paymentFraction] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.unitPrice] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun paymentFraction(paymentFraction: JsonField) = apply { - this.paymentFraction = paymentFraction + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice } fun additionalProperties(additionalProperties: Map) = apply { @@ -28133,16 +32566,12 @@ private constructor( } /** - * Returns an immutable instance of [DiscountConfiguration]. + * Returns an immutable instance of [InvoiceAmount]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DiscountConfiguration = - DiscountConfiguration( - cap, - paymentFraction, - additionalProperties.toMutableMap(), - ) + fun build(): InvoiceAmount = + InvoiceAmount(quantity, unitPrice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -28157,13 +32586,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): DiscountConfiguration = apply { + fun validate(): InvoiceAmount = apply { if (validated) { return@apply } - cap().ifPresent { it.validate() } - paymentFraction() + quantity() + unitPrice() validated = true } @@ -28175,299 +32604,86 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cap.asKnown().getOrNull()?.validity() ?: 0) + - (if (paymentFraction.asKnown().isPresent) 1 else 0) - - /** Update the discount cap. Set to null to remove an existing cap. */ - class Cap - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val spendTrackerAlias: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("spend_tracker_alias") - @ExcludeMissing - spendTrackerAlias: JsonField = JsonMissing.of(), - ) : this(amount, spendTrackerAlias, mutableMapOf()) - - /** - * Accumulated spend ceiling above which the discount stops applying. - * - * @throws MetronomeInvalidDataException if 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") - - /** - * Alias of the spend tracker this cap is measured against. - * - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun spendTrackerAlias(): String = - spendTrackerAlias.getRequired("spend_tracker_alias") - - /** - * 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 [spendTrackerAlias]. - * - * Unlike [spendTrackerAlias], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("spend_tracker_alias") - @ExcludeMissing - fun _spendTrackerAlias(): JsonField = spendTrackerAlias - - @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 [Cap]. - * - * The following fields are required: - * ```java - * .amount() - * .spendTrackerAlias() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Cap]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var spendTrackerAlias: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(cap: Cap) = apply { - amount = cap.amount - spendTrackerAlias = cap.spendTrackerAlias - additionalProperties = cap.additionalProperties.toMutableMap() - } - - /** Accumulated spend ceiling above which the discount stops applying. */ - 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 } - - /** Alias of the spend tracker this cap is measured against. */ - fun spendTrackerAlias(spendTrackerAlias: String) = - spendTrackerAlias(JsonField.of(spendTrackerAlias)) - - /** - * Sets [Builder.spendTrackerAlias] to an arbitrary JSON value. - * - * You should usually call [Builder.spendTrackerAlias] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun spendTrackerAlias(spendTrackerAlias: JsonField) = apply { - this.spendTrackerAlias = spendTrackerAlias - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Cap]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .spendTrackerAlias() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Cap = - Cap( - checkRequired("amount", amount), - checkRequired("spendTrackerAlias", spendTrackerAlias), - 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 MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. - */ - fun validate(): Cap = apply { - if (validated) { - return@apply - } - - amount() - spendTrackerAlias() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a 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 (spendTrackerAlias.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cap && - amount == other.amount && - spendTrackerAlias == other.spendTrackerAlias && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, spendTrackerAlias, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Cap{amount=$amount, spendTrackerAlias=$spendTrackerAlias, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is DiscountConfiguration && - cap == other.cap && - paymentFraction == other.paymentFraction && + return other is InvoiceAmount && + quantity == other.quantity && + unitPrice == other.unitPrice && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(cap, paymentFraction, additionalProperties) + Objects.hash(quantity, unitPrice, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "DiscountConfiguration{cap=$cap, paymentFraction=$paymentFraction, additionalProperties=$additionalProperties}" + "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class ThresholdBalanceSpecifier + /** Rounding configuration for prorated recurring commit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val exclude: JsonField>, + private val access: JsonField, + private val invoice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("exclude") + @JsonProperty("access") @ExcludeMissing - exclude: JsonField> = JsonMissing.of() - ) : this(exclude, mutableMapOf()) + access: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + ) : this(access, invoice, mutableMapOf()) /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun exclude(): List = exclude.getRequired("exclude") + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [exclude]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * Returns the raw JSON value of [access]. * - * Unlike [exclude], this method doesn't throw if the JSON field has an unexpected + * Unlike [access], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("exclude") + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice") @ExcludeMissing - fun _exclude(): JsonField> = exclude + fun _invoice(): JsonField = invoice @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28485,54 +32701,46 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ThresholdBalanceSpecifier]. - * - * The following fields are required: - * ```java - * .exclude() - * ``` + * [ProrationRounding]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [ThresholdBalanceSpecifier]. */ + /** A builder for [ProrationRounding]. */ class Builder internal constructor() { - private var exclude: JsonField>? = null + private var access: JsonField = JsonMissing.of() + private var invoice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(thresholdBalanceSpecifier: ThresholdBalanceSpecifier) = - apply { - exclude = thresholdBalanceSpecifier.exclude.map { it.toMutableList() } - additionalProperties = - thresholdBalanceSpecifier.additionalProperties.toMutableMap() - } + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + invoice = prorationRounding.invoice + additionalProperties = prorationRounding.additionalProperties.toMutableMap() + } - fun exclude(exclude: List) = exclude(JsonField.of(exclude)) + fun access(access: Access) = access(JsonField.of(access)) /** - * Sets [Builder.exclude] to an arbitrary JSON value. + * Sets [Builder.access] to an arbitrary JSON value. * - * You should usually call [Builder.exclude] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun exclude(exclude: JsonField>) = apply { - this.exclude = exclude.map { it.toMutableList() } - } + fun access(access: JsonField) = apply { this.access = access } + + fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) /** - * Adds a single [Exclude] to [Builder.exclude]. + * Sets [Builder.invoice] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.invoice] with a well-typed [Invoice] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun addExclude(exclude: Exclude) = apply { - this.exclude = - (this.exclude ?: JsonField.of(mutableListOf())).also { - checkKnown("exclude", it).add(exclude) - } - } + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28557,22 +32765,12 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdBalanceSpecifier]. + * Returns an immutable instance of [ProrationRounding]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .exclude() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): ThresholdBalanceSpecifier = - ThresholdBalanceSpecifier( - checkRequired("exclude", exclude).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): ProrationRounding = + ProrationRounding(access, invoice, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -28587,12 +32785,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): ThresholdBalanceSpecifier = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - exclude().forEach { it.validate() } + access().ifPresent { it.validate() } + invoice().ifPresent { it.validate() } validated = true } @@ -28612,40 +32811,65 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (exclude.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (access.asKnown().getOrNull()?.validity() ?: 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) - class Exclude + class Access @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val customFieldFilters: JsonField>, + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - customFieldFilters: JsonField> = JsonMissing.of() - ) : this(customFieldFilters, mutableMapOf()) + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected * type or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun customFieldFilters(): List = - customFieldFilters.getRequired("custom_field_filters") + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") /** - * Returns the raw JSON value of [customFieldFilters]. + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") + + /** + * Returns the raw JSON value of [decimalPlaces]. * - * Unlike [customFieldFilters], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("custom_field_filters") + @JsonProperty("decimal_places") @ExcludeMissing - fun _customFieldFilters(): JsonField> = - customFieldFilters + fun _decimalPlaces(): JsonField = decimalPlaces + + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -28662,58 +32886,63 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Exclude]. + * Returns a mutable builder for constructing an instance of [Access]. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Exclude]. */ + /** A builder for [Access]. */ class Builder internal constructor() { - private var customFieldFilters: JsonField>? = - null + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(exclude: Exclude) = apply { - customFieldFilters = - exclude.customFieldFilters.map { it.toMutableList() } - additionalProperties = exclude.additionalProperties.toMutableMap() + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() } - fun customFieldFilters(customFieldFilters: List) = - customFieldFilters(JsonField.of(customFieldFilters)) + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Sets [Builder.customFieldFilters] to an arbitrary JSON value. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * You should usually call [Builder.customFieldFilters] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun customFieldFilters( - customFieldFilters: JsonField> - ) = apply { - this.customFieldFilters = customFieldFilters.map { it.toMutableList() } + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + /** - * Adds a single [CustomFieldFilter] to [customFieldFilters]. + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun addCustomFieldFilter(customFieldFilter: CustomFieldFilter) = apply { - customFieldFilters = - (customFieldFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("customFieldFilters", it).add(customFieldFilter) - } + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod } fun additionalProperties(additionalProperties: Map) = @@ -28739,22 +32968,22 @@ private constructor( } /** - * Returns an immutable instance of [Exclude]. + * Returns an immutable instance of [Access]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .customFieldFilters() + * .decimalPlaces() + * .roundingMethod() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Exclude = - Exclude( - checkRequired("customFieldFilters", customFieldFilters).map { - it.toImmutable() - }, + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), additionalProperties.toMutableMap(), ) } @@ -28771,12 +33000,13 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object * doesn't match its expected type. */ - fun validate(): Exclude = apply { + fun validate(): Access = apply { if (validated) { return@apply } - customFieldFilters().forEach { it.validate() } + decimalPlaces() + roundingMethod().validate() validated = true } @@ -28796,425 +33026,553 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (customFieldFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - class CustomFieldFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val entity: JsonField, - private val key: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JsonCreator - private constructor( - @JsonProperty("entity") - @ExcludeMissing - entity: JsonField = JsonMissing.of(), - @JsonProperty("key") - @ExcludeMissing - key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(entity, key, value, mutableMapOf()) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HALF_UP = of("HALF_UP") + + @JvmField val FLOOR = of("FLOOR") + + @JvmField val CEILING = of("CEILING") + + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } + + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun entity(): Entity = entity.getRequired("entity") + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. */ - fun key(): String = key.getRequired("key") + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. */ - fun value(): String = value.getRequired("value") + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } /** - * Returns the raw JSON value of [entity]. + * Returns this class instance's primitive wire representation. * - * Unlike [entity], this method doesn't throw if the JSON field has an - * unexpected type. + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. */ - @JsonProperty("entity") - @ExcludeMissing - fun _entity(): JsonField = entity + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false /** - * Returns the raw JSON value of [key]. + * Validates that the types of all values in this object match their + * expected types recursively. * - * Unlike [key], this method doesn't throw if the JSON field has an - * unexpected type. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. */ - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } /** - * Returns the raw JSON value of [value]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + return other is RoundingMethod && value == other.value + } - fun toBuilder() = Builder().from(this) + override fun hashCode() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - /** - * Returns a mutable builder for constructing an instance of - * [CustomFieldFilter]. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [CustomFieldFilter]. */ - class Builder internal constructor() { + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties + } - private var entity: JsonField? = null - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) + } - @JvmSynthetic - internal fun from(customFieldFilter: CustomFieldFilter) = apply { - entity = customFieldFilter.entity - key = customFieldFilter.key - value = customFieldFilter.value - additionalProperties = - customFieldFilter.additionalProperties.toMutableMap() - } + override fun hashCode(): Int = hashCode - fun entity(entity: Entity) = entity(JsonField.of(entity)) + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.entity] to an arbitrary JSON value. - * - * You should usually call [Builder.entity] with a well-typed [Entity] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun entity(entity: JsonField) = apply { this.entity = entity } + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - fun key(key: String) = key(JsonField.of(key)) + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - /** - * Sets [Builder.key] to an arbitrary JSON value. - * - * You should usually call [Builder.key] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun key(key: JsonField) = apply { this.key = key } + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - fun value(value: String) = value(JsonField.of(value)) + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [CustomFieldFilter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .entity() - * .key() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CustomFieldFilter = - CustomFieldFilter( - checkRequired("entity", entity), - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + decimalPlaces = invoice.decimalPlaces + roundingMethod = invoice.roundingMethod + additionalProperties = invoice.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) /** - * Validates that the types of all values in this object match their - * expected types recursively. + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. * - * This method is _not_ forwards compatible with new types from the API for - * existing fields. + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } + + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) + + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. * - * @throws MetronomeInvalidDataException if any value type in this object - * doesn't match its expected type. + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun validate(): CustomFieldFilter = apply { - if (validated) { - return@apply + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - entity().validate() - key() - value() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [Invoice]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (entity.asKnown().getOrNull()?.validity() ?: 0) + - (if (key.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) + fun build(): Invoice = + Invoice( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - class Entity - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var validated: Boolean = false - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } - companion object { + decimalPlaces() + roundingMethod().validate() + validated = true + } - @JvmField val COMMIT = of("Commit") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - @JvmField val CONTRACT_CREDIT = of("ContractCredit") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) - @JvmField - val CONTRACT_CREDIT_OR_COMMIT = of("ContractCreditOrCommit") + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JvmStatic fun of(value: String) = Entity(JsonField.of(value)) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** An enum containing [Entity]'s known values. */ - enum class Known { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - } + companion object { - /** - * An enum containing [Entity]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Entity] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMIT, - CONTRACT_CREDIT, - CONTRACT_CREDIT_OR_COMMIT, - /** - * An enum member indicating that [Entity] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val HALF_UP = of("HALF_UP") - /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMIT -> Value.COMMIT - CONTRACT_CREDIT -> Value.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Value.CONTRACT_CREDIT_OR_COMMIT - else -> Value._UNKNOWN - } + @JvmField val FLOOR = of("FLOOR") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - COMMIT -> Known.COMMIT - CONTRACT_CREDIT -> Known.CONTRACT_CREDIT - CONTRACT_CREDIT_OR_COMMIT -> Known.CONTRACT_CREDIT_OR_COMMIT - else -> - throw MetronomeInvalidDataException( - "Unknown Entity: $value" - ) - } + @JvmField val CEILING = of("CEILING") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") - } + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, /** - * Validates that the types of all values in this object match their - * expected types recursively. - * - * This method is _not_ forwards compatible with new types from the API - * for existing fields. - * - * @throws MetronomeInvalidDataException if any value type in this - * object doesn't match its expected type. + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. */ - fun validate(): Entity = apply { - if (validated) { - return@apply - } + _UNKNOWN, + } - known() - validated = true + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - return other is Entity && value == other.value + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") } - override fun hashCode() = value.hashCode() + private var validated: Boolean = false - override fun toString() = value.toString() + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CustomFieldFilter && - entity == other.entity && - key == other.key && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(entity, key, value, additionalProperties) + return other is RoundingMethod && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CustomFieldFilter{entity=$entity, key=$key, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -29222,19 +33580,20 @@ private constructor( return true } - return other is Exclude && - customFieldFilters == other.customFieldFilters && + return other is Invoice && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(customFieldFilters, additionalProperties) + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Exclude{customFieldFilters=$customFieldFilters, additionalProperties=$additionalProperties}" + "Invoice{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -29242,17 +33601,161 @@ private constructor( return true } - return other is ThresholdBalanceSpecifier && - exclude == other.exclude && + return other is ProrationRounding && + access == other.access && + invoice == other.invoice && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(exclude, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(access, invoice, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdBalanceSpecifier{exclude=$exclude, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, invoice=$invoice, additionalProperties=$additionalProperties}" + } + + class RateType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST_RATE = of("LIST_RATE") + + @JvmField val COMMIT_RATE = of("COMMIT_RATE") + + @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) + } + + /** An enum containing [RateType]'s known values. */ + enum class Known { + LIST_RATE, + COMMIT_RATE, + } + + /** + * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RateType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST_RATE, + COMMIT_RATE, + /** + * An enum member indicating that [RateType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST_RATE -> Value.LIST_RATE + COMMIT_RATE -> Value.COMMIT_RATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIST_RATE -> Known.LIST_RATE + COMMIT_RATE -> Known.COMMIT_RATE + else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws MetronomeInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): RateType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RateType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -29260,28 +33763,24 @@ private constructor( return true } - return other is UpdatePrepaidBalanceThresholdConfiguration && - commit == other.commit && - customCreditTypeId == other.customCreditTypeId && - discountConfiguration == other.discountConfiguration && - isEnabled == other.isEnabled && - paymentGateConfig == other.paymentGateConfig && - rechargeToAmount == other.rechargeToAmount && - thresholdAmount == other.thresholdAmount && - thresholdBalanceSpecifiers == other.thresholdBalanceSpecifiers && + return other is UpdateRecurringCommit && + id == other.id && + accessAmount == other.accessAmount && + endingBefore == other.endingBefore && + invoiceAmount == other.invoiceAmount && + prorationRounding == other.prorationRounding && + rateType == other.rateType && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - commit, - customCreditTypeId, - discountConfiguration, - isEnabled, - paymentGateConfig, - rechargeToAmount, - thresholdAmount, - thresholdBalanceSpecifiers, + id, + accessAmount, + endingBefore, + invoiceAmount, + prorationRounding, + rateType, additionalProperties, ) } @@ -29289,16 +33788,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdatePrepaidBalanceThresholdConfiguration{commit=$commit, customCreditTypeId=$customCreditTypeId, discountConfiguration=$discountConfiguration, isEnabled=$isEnabled, paymentGateConfig=$paymentGateConfig, rechargeToAmount=$rechargeToAmount, thresholdAmount=$thresholdAmount, thresholdBalanceSpecifiers=$thresholdBalanceSpecifiers, additionalProperties=$additionalProperties}" + "UpdateRecurringCommit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } - class UpdateRecurringCommit + class UpdateRecurringCredit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val accessAmount: JsonField, private val endingBefore: JsonField, - private val invoiceAmount: JsonField, + private val prorationRounding: JsonField, private val rateType: JsonField, private val additionalProperties: MutableMap, ) { @@ -29312,13 +33811,13 @@ private constructor( @JsonProperty("ending_before") @ExcludeMissing endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - invoiceAmount: JsonField = JsonMissing.of(), + prorationRounding: JsonField = JsonMissing.of(), @JsonProperty("rate_type") @ExcludeMissing rateType: JsonField = JsonMissing.of(), - ) : this(id, accessAmount, endingBefore, invoiceAmount, rateType, mutableMapOf()) + ) : this(id, accessAmount, endingBefore, prorationRounding, rateType, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is @@ -29340,11 +33839,13 @@ private constructor( fun endingBefore(): Optional = endingBefore.getOptional("ending_before") /** + * Rounding configuration for prorated recurring credit amounts. + * * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun invoiceAmount(): Optional = - invoiceAmount.getOptional("invoice_amount") + fun prorationRounding(): Optional = + prorationRounding.getOptional("proration_rounding") /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. @@ -29380,14 +33881,14 @@ private constructor( fun _endingBefore(): JsonField = endingBefore /** - * Returns the raw JSON value of [invoiceAmount]. - * - * Unlike [invoiceAmount], this method doesn't throw if the JSON field has an unexpected - * type. + * Returns the raw JSON value of [prorationRounding]. + * + * Unlike [prorationRounding], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("invoice_amount") + @JsonProperty("proration_rounding") @ExcludeMissing - fun _invoiceAmount(): JsonField = invoiceAmount + fun _prorationRounding(): JsonField = prorationRounding /** * Returns the raw JSON value of [rateType]. @@ -29415,7 +33916,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UpdateRecurringCommit]. + * [UpdateRecurringCredit]. * * The following fields are required: * ```java @@ -29425,24 +33926,24 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UpdateRecurringCommit]. */ + /** A builder for [UpdateRecurringCredit]. */ class Builder internal constructor() { private var id: JsonField? = null private var accessAmount: JsonField = JsonMissing.of() private var endingBefore: JsonField = JsonMissing.of() - private var invoiceAmount: JsonField = JsonMissing.of() + private var prorationRounding: JsonField = JsonMissing.of() private var rateType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(updateRecurringCommit: UpdateRecurringCommit) = apply { - id = updateRecurringCommit.id - accessAmount = updateRecurringCommit.accessAmount - endingBefore = updateRecurringCommit.endingBefore - invoiceAmount = updateRecurringCommit.invoiceAmount - rateType = updateRecurringCommit.rateType - additionalProperties = updateRecurringCommit.additionalProperties.toMutableMap() + internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { + id = updateRecurringCredit.id + accessAmount = updateRecurringCredit.accessAmount + endingBefore = updateRecurringCredit.endingBefore + prorationRounding = updateRecurringCredit.prorationRounding + rateType = updateRecurringCredit.rateType + additionalProperties = updateRecurringCredit.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -29484,18 +33985,26 @@ private constructor( this.endingBefore = endingBefore } - fun invoiceAmount(invoiceAmount: InvoiceAmount) = - invoiceAmount(JsonField.of(invoiceAmount)) + /** Rounding configuration for prorated recurring credit amounts. */ + fun prorationRounding(prorationRounding: ProrationRounding?) = + prorationRounding(JsonField.ofNullable(prorationRounding)) /** - * Sets [Builder.invoiceAmount] to an arbitrary JSON value. + * Alias for calling [Builder.prorationRounding] with + * `prorationRounding.orElse(null)`. + */ + fun prorationRounding(prorationRounding: Optional) = + prorationRounding(prorationRounding.getOrNull()) + + /** + * Sets [Builder.prorationRounding] to an arbitrary JSON value. * - * You should usually call [Builder.invoiceAmount] with a well-typed [InvoiceAmount] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.prorationRounding] with a well-typed + * [ProrationRounding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun invoiceAmount(invoiceAmount: JsonField) = apply { - this.invoiceAmount = invoiceAmount + fun prorationRounding(prorationRounding: JsonField) = apply { + this.prorationRounding = prorationRounding } fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) @@ -29532,7 +34041,7 @@ private constructor( } /** - * Returns an immutable instance of [UpdateRecurringCommit]. + * Returns an immutable instance of [UpdateRecurringCredit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -29543,12 +34052,12 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UpdateRecurringCommit = - UpdateRecurringCommit( + fun build(): UpdateRecurringCredit = + UpdateRecurringCredit( checkRequired("id", id), accessAmount, endingBefore, - invoiceAmount, + prorationRounding, rateType, additionalProperties.toMutableMap(), ) @@ -29566,7 +34075,7 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't match * its expected type. */ - fun validate(): UpdateRecurringCommit = apply { + fun validate(): UpdateRecurringCredit = apply { if (validated) { return@apply } @@ -29574,7 +34083,7 @@ private constructor( id() accessAmount().ifPresent { it.validate() } endingBefore() - invoiceAmount().ifPresent { it.validate() } + prorationRounding().ifPresent { it.validate() } rateType().ifPresent { it.validate() } validated = true } @@ -29598,7 +34107,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + (if (endingBefore.asKnown().isPresent) 1 else 0) + - (invoiceAmount.asKnown().getOrNull()?.validity() ?: 0) + + (prorationRounding.asKnown().getOrNull()?.validity() ?: 0) + (rateType.asKnown().getOrNull()?.validity() ?: 0) class AccessAmount @@ -29800,55 +34309,34 @@ private constructor( "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - class InvoiceAmount + /** Rounding configuration for prorated recurring credit amounts. */ + class ProrationRounding @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, + private val access: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + @JsonProperty("access") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + access: JsonField = JsonMissing.of() + ) : this(access, mutableMapOf()) /** * @throws MetronomeInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") - - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + fun access(): Optional = access.getOptional("access") /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [access]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [access], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JsonProperty("access") @ExcludeMissing fun _access(): JsonField = access @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -29865,233 +34353,66 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [InvoiceAmount]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceAmount]. */ - class Builder internal constructor() { - - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceAmount: InvoiceAmount) = apply { - quantity = invoiceAmount.quantity - unitPrice = invoiceAmount.unitPrice - additionalProperties = invoiceAmount.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) - - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InvoiceAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InvoiceAmount = - InvoiceAmount(quantity, unitPrice, 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 MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): InvoiceAmount = apply { - if (validated) { - return@apply - } - - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InvoiceAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" - } - - class RateType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST_RATE = of("LIST_RATE") - - @JvmField val COMMIT_RATE = of("COMMIT_RATE") - - @JvmStatic fun of(value: String) = RateType(JsonField.of(value)) - } - - /** An enum containing [RateType]'s known values. */ - enum class Known { - LIST_RATE, - COMMIT_RATE, - } - - /** - * An enum containing [RateType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RateType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST_RATE, - COMMIT_RATE, - /** - * An enum member indicating that [RateType] was instantiated with an unknown - * value. + * Returns a mutable builder for constructing an instance of + * [ProrationRounding]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST_RATE -> Value.LIST_RATE - COMMIT_RATE -> Value.COMMIT_RATE - else -> Value._UNKNOWN + /** A builder for [ProrationRounding]. */ + class Builder internal constructor() { + + private var access: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prorationRounding: ProrationRounding) = apply { + access = prorationRounding.access + additionalProperties = prorationRounding.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws MetronomeInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - LIST_RATE -> Known.LIST_RATE - COMMIT_RATE -> Known.COMMIT_RATE - else -> throw MetronomeInvalidDataException("Unknown RateType: $value") + fun access(access: Access) = access(JsonField.of(access)) + + /** + * Sets [Builder.access] to an arbitrary JSON value. + * + * You should usually call [Builder.access] with a well-typed [Access] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun access(access: JsonField) = apply { this.access = access } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws MetronomeInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - MetronomeInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProrationRounding]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProrationRounding = + ProrationRounding(access, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false /** @@ -30104,12 +34425,12 @@ private constructor( * @throws MetronomeInvalidDataException if any value type in this object doesn't * match its expected type. */ - fun validate(): RateType = apply { + fun validate(): ProrationRounding = apply { if (validated) { return@apply } - known() + access().ifPresent { it.validate() } validated = true } @@ -30127,518 +34448,416 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RateType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UpdateRecurringCommit && - id == other.id && - accessAmount == other.accessAmount && - endingBefore == other.endingBefore && - invoiceAmount == other.invoiceAmount && - rateType == other.rateType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accessAmount, - endingBefore, - invoiceAmount, - rateType, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UpdateRecurringCommit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, invoiceAmount=$invoiceAmount, rateType=$rateType, additionalProperties=$additionalProperties}" - } - - class UpdateRecurringCredit - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val accessAmount: JsonField, - private val endingBefore: JsonField, - private val rateType: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("access_amount") - @ExcludeMissing - accessAmount: JsonField = JsonMissing.of(), - @JsonProperty("ending_before") - @ExcludeMissing - endingBefore: JsonField = JsonMissing.of(), - @JsonProperty("rate_type") - @ExcludeMissing - rateType: JsonField = JsonMissing.of(), - ) : this(id, accessAmount, endingBefore, rateType, mutableMapOf()) - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun accessAmount(): Optional = accessAmount.getOptional("access_amount") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun endingBefore(): Optional = endingBefore.getOptional("ending_before") - - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun rateType(): Optional = rateType.getOptional("rate_type") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [accessAmount]. - * - * Unlike [accessAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("access_amount") - @ExcludeMissing - fun _accessAmount(): JsonField = accessAmount - - /** - * Returns the raw JSON value of [endingBefore]. - * - * Unlike [endingBefore], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ending_before") - @ExcludeMissing - fun _endingBefore(): JsonField = endingBefore - - /** - * Returns the raw JSON value of [rateType]. - * - * Unlike [rateType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rate_type") - @ExcludeMissing - fun _rateType(): JsonField = rateType - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmSynthetic + internal fun validity(): Int = (access.asKnown().getOrNull()?.validity() ?: 0) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + class Access + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val decimalPlaces: JsonField, + private val roundingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { - fun toBuilder() = Builder().from(this) + @JsonCreator + private constructor( + @JsonProperty("decimal_places") + @ExcludeMissing + decimalPlaces: JsonField = JsonMissing.of(), + @JsonProperty("rounding_method") + @ExcludeMissing + roundingMethod: JsonField = JsonMissing.of(), + ) : this(decimalPlaces, roundingMethod, mutableMapOf()) - companion object { + /** + * Number of decimal places to round to. Applied directly to the stored monetary + * representation. Negative values round to powers of 10 (e.g., -2 rounds to + * nearest 100 in the stored unit). + * + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun decimalPlaces(): Double = decimalPlaces.getRequired("decimal_places") - /** - * Returns a mutable builder for constructing an instance of - * [UpdateRecurringCredit]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws MetronomeInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun roundingMethod(): RoundingMethod = + roundingMethod.getRequired("rounding_method") - /** A builder for [UpdateRecurringCredit]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [decimalPlaces]. + * + * Unlike [decimalPlaces], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("decimal_places") + @ExcludeMissing + fun _decimalPlaces(): JsonField = decimalPlaces - private var id: JsonField? = null - private var accessAmount: JsonField = JsonMissing.of() - private var endingBefore: JsonField = JsonMissing.of() - private var rateType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [roundingMethod]. + * + * Unlike [roundingMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rounding_method") + @ExcludeMissing + fun _roundingMethod(): JsonField = roundingMethod - @JvmSynthetic - internal fun from(updateRecurringCredit: UpdateRecurringCredit) = apply { - id = updateRecurringCredit.id - accessAmount = updateRecurringCredit.accessAmount - endingBefore = updateRecurringCredit.endingBefore - rateType = updateRecurringCredit.rateType - additionalProperties = updateRecurringCredit.additionalProperties.toMutableMap() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun id(id: String) = id(JsonField.of(id)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + fun toBuilder() = Builder().from(this) - fun accessAmount(accessAmount: AccessAmount) = - accessAmount(JsonField.of(accessAmount)) + companion object { - /** - * Sets [Builder.accessAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.accessAmount] with a well-typed [AccessAmount] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun accessAmount(accessAmount: JsonField) = apply { - this.accessAmount = accessAmount - } + /** + * Returns a mutable builder for constructing an instance of [Access]. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun endingBefore(endingBefore: OffsetDateTime) = - endingBefore(JsonField.of(endingBefore)) + /** A builder for [Access]. */ + class Builder internal constructor() { - /** - * Sets [Builder.endingBefore] to an arbitrary JSON value. - * - * You should usually call [Builder.endingBefore] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun endingBefore(endingBefore: JsonField) = apply { - this.endingBefore = endingBefore - } + private var decimalPlaces: JsonField? = null + private var roundingMethod: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun rateType(rateType: RateType) = rateType(JsonField.of(rateType)) + @JvmSynthetic + internal fun from(access: Access) = apply { + decimalPlaces = access.decimalPlaces + roundingMethod = access.roundingMethod + additionalProperties = access.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.rateType] to an arbitrary JSON value. - * - * You should usually call [Builder.rateType] with a well-typed [RateType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun rateType(rateType: JsonField) = apply { this.rateType = rateType } + /** + * Number of decimal places to round to. Applied directly to the stored + * monetary representation. Negative values round to powers of 10 (e.g., -2 + * rounds to nearest 100 in the stored unit). + */ + fun decimalPlaces(decimalPlaces: Double) = + decimalPlaces(JsonField.of(decimalPlaces)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.decimalPlaces] to an arbitrary JSON value. + * + * You should usually call [Builder.decimalPlaces] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun decimalPlaces(decimalPlaces: JsonField) = apply { + this.decimalPlaces = decimalPlaces + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun roundingMethod(roundingMethod: RoundingMethod) = + roundingMethod(JsonField.of(roundingMethod)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.roundingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.roundingMethod] with a well-typed + * [RoundingMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun roundingMethod(roundingMethod: JsonField) = apply { + this.roundingMethod = roundingMethod + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns an immutable instance of [UpdateRecurringCredit]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UpdateRecurringCredit = - UpdateRecurringCredit( - checkRequired("id", id), - accessAmount, - endingBefore, - rateType, - additionalProperties.toMutableMap(), - ) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - private var validated: Boolean = false + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): UpdateRecurringCredit = apply { - if (validated) { - return@apply - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - id() - accessAmount().ifPresent { it.validate() } - endingBefore() - rateType().ifPresent { it.validate() } - validated = true - } + /** + * Returns an immutable instance of [Access]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .decimalPlaces() + * .roundingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Access = + Access( + checkRequired("decimalPlaces", decimalPlaces), + checkRequired("roundingMethod", roundingMethod), + additionalProperties.toMutableMap(), + ) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (accessAmount.asKnown().getOrNull()?.validity() ?: 0) + - (if (endingBefore.asKnown().isPresent) 1 else 0) + - (rateType.asKnown().getOrNull()?.validity() ?: 0) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): Access = apply { + if (validated) { + return@apply + } - class AccessAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val quantity: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + decimalPlaces() + roundingMethod().validate() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this(quantity, unitPrice, mutableMapOf()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (decimalPlaces.asKnown().isPresent) 1 else 0) + + (roundingMethod.asKnown().getOrNull()?.validity() ?: 0) + + class RoundingMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * @throws MetronomeInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity + companion object { - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + @JvmField val HALF_UP = of("HALF_UP") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val FLOOR = of("FLOOR") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val CEILING = of("CEILING") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = RoundingMethod(JsonField.of(value)) + } - companion object { + /** An enum containing [RoundingMethod]'s known values. */ + enum class Known { + HALF_UP, + FLOOR, + CEILING, + } - /** Returns a mutable builder for constructing an instance of [AccessAmount]. */ - @JvmStatic fun builder() = Builder() - } + /** + * An enum containing [RoundingMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RoundingMethod] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HALF_UP, + FLOOR, + CEILING, + /** + * An enum member indicating that [RoundingMethod] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - /** A builder for [AccessAmount]. */ - class Builder internal constructor() { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HALF_UP -> Value.HALF_UP + FLOOR -> Value.FLOOR + CEILING -> Value.CEILING + else -> Value._UNKNOWN + } - private var quantity: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws MetronomeInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + HALF_UP -> Known.HALF_UP + FLOOR -> Known.FLOOR + CEILING -> Known.CEILING + else -> + throw MetronomeInvalidDataException( + "Unknown RoundingMethod: $value" + ) + } - @JvmSynthetic - internal fun from(accessAmount: AccessAmount) = apply { - quantity = accessAmount.quantity - unitPrice = accessAmount.unitPrice - additionalProperties = accessAmount.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws MetronomeInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + MetronomeInvalidDataException("Value is not a String") + } - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + private var validated: Boolean = false - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws MetronomeInvalidDataException if any value type in this object + * doesn't match its expected type. + */ + fun validate(): RoundingMethod = apply { + if (validated) { + return@apply + } - fun unitPrice(unitPrice: Double) = unitPrice(JsonField.of(unitPrice)) + known() + validated = true + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { - this.unitPrice = unitPrice - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: MetronomeInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + return other is RoundingMethod && value == other.value } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun hashCode() = value.hashCode() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun toString() = value.toString() } - /** - * Returns an immutable instance of [AccessAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AccessAmount = - AccessAmount(quantity, unitPrice, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws MetronomeInvalidDataException if any value type in this object doesn't - * match its expected type. - */ - fun validate(): AccessAmount = apply { - if (validated) { - return@apply + return other is Access && + decimalPlaces == other.decimalPlaces && + roundingMethod == other.roundingMethod && + additionalProperties == other.additionalProperties } - quantity() - unitPrice() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: MetronomeInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(decimalPlaces, roundingMethod, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "Access{decimalPlaces=$decimalPlaces, roundingMethod=$roundingMethod, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AccessAmount && - quantity == other.quantity && - unitPrice == other.unitPrice && + return other is ProrationRounding && + access == other.access && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(quantity, unitPrice, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(access, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AccessAmount{quantity=$quantity, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "ProrationRounding{access=$access, additionalProperties=$additionalProperties}" } class RateType @JsonCreator private constructor(private val value: JsonField) : @@ -30791,18 +35010,26 @@ private constructor( id == other.id && accessAmount == other.accessAmount && endingBefore == other.endingBefore && + prorationRounding == other.prorationRounding && rateType == other.rateType && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, accessAmount, endingBefore, rateType, additionalProperties) + Objects.hash( + id, + accessAmount, + endingBefore, + prorationRounding, + rateType, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "UpdateRecurringCredit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, rateType=$rateType, additionalProperties=$additionalProperties}" + "UpdateRecurringCredit{id=$id, accessAmount=$accessAmount, endingBefore=$endingBefore, prorationRounding=$prorationRounding, rateType=$rateType, additionalProperties=$additionalProperties}" } class UpdateRefundInvoice diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsync.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsync.kt index eaad47ca..c43d5330 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsync.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsync.kt @@ -17,6 +17,8 @@ import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractCreateResponse import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceResponse +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryResponse import com.metronome.api.models.v1.contracts.ContractListBalancesPageAsync import com.metronome.api.models.v1.contracts.ContractListBalancesParams import com.metronome.api.models.v1.contracts.ContractListParams @@ -350,6 +352,40 @@ interface ContractServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * Get the history of subscription seats schedule over time for a given `subscription_id`. This + * endpoint provides information about seat assignments and total quantities for different time + * periods, allowing you to track how seat assignments have changed over time. + * + * ### Use this endpoint to: + * - Track changes to seat assignments over time + * - Get seat schedule for a specific date using the `covering_date` parameter + * - Get seat schedule history with optional date range filtering using `starting_at` and + * `ending_before` + * + * ### Key response fields: + * - data: array of seat schedule entries with time periods, quantity, and assignments + * - next_page: cursor for pagination to retrieve additional results + * + * ### Usage guidelines: + * - Use `covering_date` to get the active seats for a specific point in time. `covering_date` + * cannot be used with `starting_at` or `ending_before`. + * - Use `starting_at` and `ending_before` to filter results by time range. `starting_at` and + * `ending_before` cannot be used with `covering_date`. + * - Maximum limit is 10 seat schedule entries per request + * - Results are ordered by `starting_at` timestamp + */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams + ): CompletableFuture = + getSubscriptionSeatsHistory(params, RequestOptions.none()) + + /** @see getSubscriptionSeatsHistory */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * Retrieve a comprehensive view of all available balances (commits and credits) for a customer. * This endpoint provides real-time visibility into prepaid funds, postpaid commitments, @@ -670,6 +706,21 @@ interface ContractServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `post /v1/contracts/getSubscriptionSeatsHistory`, but is + * otherwise the same as [ContractServiceAsync.getSubscriptionSeatsHistory]. + */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams + ): CompletableFuture> = + getSubscriptionSeatsHistory(params, RequestOptions.none()) + + /** @see getSubscriptionSeatsHistory */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /v1/contracts/customerBalances/list`, but is * otherwise the same as [ContractServiceAsync.listBalances]. diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncImpl.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncImpl.kt index 22c497fe..8bb48834 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncImpl.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncImpl.kt @@ -27,6 +27,8 @@ import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractCreateResponse import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceResponse +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryResponse import com.metronome.api.models.v1.contracts.ContractListBalancesPageAsync import com.metronome.api.models.v1.contracts.ContractListBalancesPageResponse import com.metronome.api.models.v1.contracts.ContractListBalancesParams @@ -142,6 +144,15 @@ class ContractServiceAsyncImpl internal constructor(private val clientOptions: C // post /v1/contracts/customerBalances/getNetBalance withRawResponse().getNetBalance(params, requestOptions).thenApply { it.parse() } + override fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/contracts/getSubscriptionSeatsHistory + withRawResponse().getSubscriptionSeatsHistory(params, requestOptions).thenApply { + it.parse() + } + override fun listBalances( params: ContractListBalancesParams, requestOptions: RequestOptions, @@ -474,6 +485,38 @@ class ContractServiceAsyncImpl internal constructor(private val clientOptions: C } } + private val getSubscriptionSeatsHistoryHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "contracts", "getSubscriptionSeatsHistory") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getSubscriptionSeatsHistoryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val listBalancesHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/contracts/ratecards/RateServiceAsync.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/contracts/ratecards/RateServiceAsync.kt index cacb10ed..e54bddf5 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/contracts/ratecards/RateServiceAsync.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/contracts/ratecards/RateServiceAsync.kt @@ -47,7 +47,13 @@ interface RateServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Add a new rate */ + /** + * Add a new rate + * + * This endpoint is heavily rate limited. For adding multiple rates, using the + * [addRates](https://docs.metronome.com/api-reference/rate-cards/add-rates) endpoint is + * strongly encouraged. + */ fun add(params: RateAddParams): CompletableFuture = add(params, RequestOptions.none()) diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsync.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsync.kt index 768edfb1..806f1fce 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsync.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsync.kt @@ -60,11 +60,11 @@ interface AlertServiceAsync { * - `null` - Notification has been archived * - `triggered_by`: Additional context about what caused the notification to trigger (when * applicable) + * - `updated_at`: Timestamp of when the `customer_status` was last updated * - alert: Complete threshold notification configuration including: * - Notification ID, name, and type * - Current threshold values and credit type information * - Notification status (enabled, disabled, or archived) - * - Last update timestamp * - Any applied filters (credit grant types, custom fields, group values) * * ### Usage guidelines: diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractService.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractService.kt index 29f28395..8b0e4f4e 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractService.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractService.kt @@ -18,6 +18,8 @@ import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractCreateResponse import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceResponse +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryResponse import com.metronome.api.models.v1.contracts.ContractListBalancesPage import com.metronome.api.models.v1.contracts.ContractListBalancesParams import com.metronome.api.models.v1.contracts.ContractListParams @@ -346,6 +348,40 @@ interface ContractService { requestOptions: RequestOptions = RequestOptions.none(), ): ContractGetNetBalanceResponse + /** + * Get the history of subscription seats schedule over time for a given `subscription_id`. This + * endpoint provides information about seat assignments and total quantities for different time + * periods, allowing you to track how seat assignments have changed over time. + * + * ### Use this endpoint to: + * - Track changes to seat assignments over time + * - Get seat schedule for a specific date using the `covering_date` parameter + * - Get seat schedule history with optional date range filtering using `starting_at` and + * `ending_before` + * + * ### Key response fields: + * - data: array of seat schedule entries with time periods, quantity, and assignments + * - next_page: cursor for pagination to retrieve additional results + * + * ### Usage guidelines: + * - Use `covering_date` to get the active seats for a specific point in time. `covering_date` + * cannot be used with `starting_at` or `ending_before`. + * - Use `starting_at` and `ending_before` to filter results by time range. `starting_at` and + * `ending_before` cannot be used with `covering_date`. + * - Maximum limit is 10 seat schedule entries per request + * - Results are ordered by `starting_at` timestamp + */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams + ): ContractGetSubscriptionSeatsHistoryResponse = + getSubscriptionSeatsHistory(params, RequestOptions.none()) + + /** @see getSubscriptionSeatsHistory */ + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ContractGetSubscriptionSeatsHistoryResponse + /** * Retrieve a comprehensive view of all available balances (commits and credits) for a customer. * This endpoint provides real-time visibility into prepaid funds, postpaid commitments, @@ -660,6 +696,23 @@ interface ContractService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `post /v1/contracts/getSubscriptionSeatsHistory`, but is + * otherwise the same as [ContractService.getSubscriptionSeatsHistory]. + */ + @MustBeClosed + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams + ): HttpResponseFor = + getSubscriptionSeatsHistory(params, RequestOptions.none()) + + /** @see getSubscriptionSeatsHistory */ + @MustBeClosed + fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /v1/contracts/customerBalances/list`, but is * otherwise the same as [ContractService.listBalances]. diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractServiceImpl.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractServiceImpl.kt index cdfe5d8b..5aabe96f 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractServiceImpl.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/ContractServiceImpl.kt @@ -27,6 +27,8 @@ import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractCreateResponse import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceResponse +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryResponse import com.metronome.api.models.v1.contracts.ContractListBalancesPage import com.metronome.api.models.v1.contracts.ContractListBalancesPageResponse import com.metronome.api.models.v1.contracts.ContractListBalancesParams @@ -142,6 +144,13 @@ class ContractServiceImpl internal constructor(private val clientOptions: Client // post /v1/contracts/customerBalances/getNetBalance withRawResponse().getNetBalance(params, requestOptions).parse() + override fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions, + ): ContractGetSubscriptionSeatsHistoryResponse = + // post /v1/contracts/getSubscriptionSeatsHistory + withRawResponse().getSubscriptionSeatsHistory(params, requestOptions).parse() + override fun listBalances( params: ContractListBalancesParams, requestOptions: RequestOptions, @@ -447,6 +456,35 @@ class ContractServiceImpl internal constructor(private val clientOptions: Client } } + private val getSubscriptionSeatsHistoryHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSubscriptionSeatsHistory( + params: ContractGetSubscriptionSeatsHistoryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "contracts", "getSubscriptionSeatsHistory") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getSubscriptionSeatsHistoryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listBalancesHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/contracts/ratecards/RateService.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/contracts/ratecards/RateService.kt index 861c9acd..04c3cca2 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/contracts/ratecards/RateService.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/contracts/ratecards/RateService.kt @@ -46,7 +46,13 @@ interface RateService { requestOptions: RequestOptions = RequestOptions.none(), ): RateListPage - /** Add a new rate */ + /** + * Add a new rate + * + * This endpoint is heavily rate limited. For adding multiple rates, using the + * [addRates](https://docs.metronome.com/api-reference/rate-cards/add-rates) endpoint is + * strongly encouraged. + */ fun add(params: RateAddParams): RateAddResponse = add(params, RequestOptions.none()) /** @see add */ diff --git a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/customers/AlertService.kt b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/customers/AlertService.kt index d03b1050..debff4c0 100644 --- a/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/customers/AlertService.kt +++ b/metronome-java-core/src/main/kotlin/com/metronome/api/services/blocking/v1/customers/AlertService.kt @@ -60,11 +60,11 @@ interface AlertService { * - `null` - Notification has been archived * - `triggered_by`: Additional context about what caused the notification to trigger (when * applicable) + * - `updated_at`: Timestamp of when the `customer_status` was last updated * - alert: Complete threshold notification configuration including: * - Notification ID, name, and type * - Current threshold values and credit type information * - Notification status (enabled, disabled, or archived) - * - Last update timestamp * - Any applied filters (credit grant types, custom fields, group values) * * ### Usage guidelines: diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/CommitTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/CommitTest.kt index d5ed64fe..05fedb7e 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/CommitTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/CommitTest.kt @@ -52,6 +52,7 @@ internal class CommitTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -195,6 +196,7 @@ internal class CommitTest { assertThat(commit.balance()).contains(0.0) assertThat(commit.contract()) .contains(Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build()) + assertThat(commit.createdBy()).contains("created_by") assertThat(commit.customFields()) .contains( Commit.CustomFields.builder() @@ -347,6 +349,7 @@ internal class CommitTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractTest.kt index 68432c2c..794b29ad 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractTest.kt @@ -64,6 +64,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -201,6 +202,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -359,6 +361,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -563,6 +566,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -700,6 +704,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -874,6 +879,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1227,6 +1233,41 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -1331,6 +1372,26 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -1579,6 +1640,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1716,6 +1778,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -1890,6 +1953,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2243,6 +2307,41 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -2347,6 +2446,26 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -2808,6 +2927,14 @@ internal class ContractTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod.HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -2833,6 +2960,15 @@ internal class ContractTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2899,6 +3035,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3029,6 +3166,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -3177,6 +3315,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3375,6 +3514,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3505,6 +3645,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -3668,6 +3809,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4004,6 +4146,39 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -4100,6 +4275,25 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -4333,6 +4527,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4463,6 +4658,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -4626,6 +4822,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4962,6 +5159,39 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -5058,6 +5288,25 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -5480,6 +5729,14 @@ internal class ContractTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod.HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -5505,6 +5762,15 @@ internal class ContractTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5575,6 +5841,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5712,6 +5979,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -5870,6 +6138,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6074,6 +6343,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6211,6 +6481,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -6385,6 +6656,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6738,6 +7010,41 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -6842,6 +7149,26 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -7090,6 +7417,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -7227,6 +7555,7 @@ internal class ContractTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -7401,6 +7730,7 @@ internal class ContractTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -7754,6 +8084,41 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -7858,6 +8223,26 @@ internal class ContractTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -8319,6 +8704,14 @@ internal class ContractTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod.HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -8344,6 +8737,15 @@ internal class ContractTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractV2Test.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractV2Test.kt index a67a48fc..b84edea2 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractV2Test.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractV2Test.kt @@ -60,6 +60,7 @@ internal class ContractV2Test { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -183,6 +184,7 @@ internal class ContractV2Test { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -347,6 +349,7 @@ internal class ContractV2Test { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -696,6 +699,30 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -781,6 +808,20 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -966,6 +1007,16 @@ internal class ContractV2Test { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -994,6 +1045,15 @@ internal class ContractV2Test { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1055,6 +1115,7 @@ internal class ContractV2Test { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1178,6 +1239,7 @@ internal class ContractV2Test { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -1344,6 +1406,7 @@ internal class ContractV2Test { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1691,6 +1754,30 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -1776,6 +1863,20 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -1945,6 +2046,15 @@ internal class ContractV2Test { ContractV2.Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1972,6 +2082,15 @@ internal class ContractV2Test { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2041,6 +2160,7 @@ internal class ContractV2Test { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2164,6 +2284,7 @@ internal class ContractV2Test { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -2328,6 +2449,7 @@ internal class ContractV2Test { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2677,6 +2799,30 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -2762,6 +2908,20 @@ internal class ContractV2Test { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency(ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY) .rolloverFraction(0.0) .addSpecifier( @@ -2947,6 +3107,16 @@ internal class ContractV2Test { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2975,6 +3145,15 @@ internal class ContractV2Test { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractWithoutAmendmentsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractWithoutAmendmentsTest.kt index 34d0e98e..d425ea3e 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractWithoutAmendmentsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/ContractWithoutAmendmentsTest.kt @@ -60,6 +60,7 @@ internal class ContractWithoutAmendmentsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -186,6 +187,7 @@ internal class ContractWithoutAmendmentsTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -343,6 +345,7 @@ internal class ContractWithoutAmendmentsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -669,6 +672,38 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -759,6 +794,24 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -971,6 +1024,7 @@ internal class ContractWithoutAmendmentsTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1099,6 +1153,7 @@ internal class ContractWithoutAmendmentsTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency(Override.OverrideSpecifier.BillingFrequency.MONTHLY) .addCommitId("string") .presentationGroupValues( @@ -1251,6 +1306,7 @@ internal class ContractWithoutAmendmentsTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1576,6 +1632,34 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -1666,6 +1750,22 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -1883,6 +1983,7 @@ internal class ContractWithoutAmendmentsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2009,6 +2110,7 @@ internal class ContractWithoutAmendmentsTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -2166,6 +2268,7 @@ internal class ContractWithoutAmendmentsTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2492,6 +2595,38 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -2582,6 +2717,24 @@ internal class ContractWithoutAmendmentsTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractWithoutAmendments.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding.builder() + .access( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit.RecurrenceFrequency.MONTHLY ) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/CreditTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/CreditTest.kt index 294f8a52..6e93d82d 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/CreditTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/CreditTest.kt @@ -49,6 +49,7 @@ internal class CreditTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -156,6 +157,7 @@ internal class CreditTest { assertThat(credit.balance()).contains(0.0) assertThat(credit.contract()) .contains(Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build()) + assertThat(credit.createdBy()).contains("created_by") assertThat(credit.customFields()) .contains( Credit.CustomFields.builder() @@ -273,6 +275,7 @@ internal class CreditTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/OverrideTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/OverrideTest.kt index d221b064..c03123bd 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/OverrideTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/OverrideTest.kt @@ -33,6 +33,7 @@ internal class OverrideTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency(Override.OverrideSpecifier.BillingFrequency.MONTHLY) .addCommitId("string") .presentationGroupValues( @@ -112,6 +113,7 @@ internal class OverrideTest { assertThat(override.overrideSpecifiers().getOrNull()) .containsExactly( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency(Override.OverrideSpecifier.BillingFrequency.MONTHLY) .addCommitId("string") .presentationGroupValues( @@ -195,6 +197,7 @@ internal class OverrideTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency(Override.OverrideSpecifier.BillingFrequency.MONTHLY) .addCommitId("string") .presentationGroupValues( diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/SubscriptionTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/SubscriptionTest.kt index 8bb5da95..5565e71a 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/SubscriptionTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/SubscriptionTest.kt @@ -42,6 +42,14 @@ internal class SubscriptionTest { Subscription.Proration.builder() .invoiceBehavior(Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod.HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -65,6 +73,14 @@ internal class SubscriptionTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement.ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -109,6 +125,12 @@ internal class SubscriptionTest { Subscription.Proration.builder() .invoiceBehavior(Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod(Subscription.Proration.Rounding.RoundingMethod.HALF_UP) + .build() + ) .build() ) assertThat(subscription.quantityManagementMode()) @@ -136,6 +158,15 @@ internal class SubscriptionTest { .build() ) assertThat(subscription.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(subscription.billingCycleConfig()) + .contains( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement.ON_SCHEDULED_INVOICE + ) + .build() + ) assertThat(subscription.customFields()) .contains( Subscription.CustomFields.builder() @@ -183,6 +214,14 @@ internal class SubscriptionTest { Subscription.Proration.builder() .invoiceBehavior(Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod.HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -206,6 +245,14 @@ internal class SubscriptionTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement.ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParamsTest.kt index f557ce0c..f55ca380 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/alerts/AlertCreateParamsTest.kt @@ -14,6 +14,34 @@ internal class AlertCreateParamsTest { .alertType(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED) .name("\$100 spend threshold reached") .threshold(10000.0) + .addAlertSpecifier( + AlertCreateParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.Entity.CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertCreateParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .billableMetricId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCreditGrantTypeFilter("enterprise") .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2") @@ -46,6 +74,37 @@ internal class AlertCreateParamsTest { .alertType(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED) .name("\$100 spend threshold reached") .threshold(10000.0) + .addAlertSpecifier( + AlertCreateParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertCreateParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertCreateParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .billableMetricId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCreditGrantTypeFilter("enterprise") .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2") @@ -77,6 +136,35 @@ internal class AlertCreateParamsTest { assertThat(body.alertType()).isEqualTo(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED) assertThat(body.name()).isEqualTo("\$100 spend threshold reached") assertThat(body.threshold()).isEqualTo(10000.0) + assertThat(body.alertSpecifiers().getOrNull()) + .containsExactly( + AlertCreateParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.Entity.CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertCreateParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) assertThat(body.billableMetricId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.creditGrantTypeFilters().getOrNull()).containsExactly("enterprise") assertThat(body.creditTypeId()).contains("2714e483-4ff1-48e4-9e25-ac732e8f24f2") diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParamsTest.kt index 34007da7..49c48134 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractAmendParamsTest.kt @@ -245,6 +245,7 @@ internal class ContractAmendParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractAmendParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractAmendParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -647,6 +648,7 @@ internal class ContractAmendParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractAmendParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractAmendParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1037,6 +1039,7 @@ internal class ContractAmendParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractAmendParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractAmendParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParamsTest.kt index 2ee73de5..157f98fb 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateParamsTest.kt @@ -293,6 +293,7 @@ internal class ContractCreateParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -511,6 +512,34 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -592,6 +621,22 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -802,6 +847,16 @@ internal class ContractCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -813,6 +868,16 @@ internal class ContractCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1166,6 +1231,7 @@ internal class ContractCreateParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1398,6 +1464,34 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -1482,6 +1576,22 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -1707,6 +1817,16 @@ internal class ContractCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1719,6 +1839,16 @@ internal class ContractCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2058,6 +2188,7 @@ internal class ContractCreateParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2279,6 +2410,34 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -2361,6 +2520,22 @@ internal class ContractCreateParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -2576,6 +2751,16 @@ internal class ContractCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2587,6 +2772,16 @@ internal class ContractCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponseTest.kt index 9c16ce9c..5ec3e1f4 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractCreateResponseTest.kt @@ -94,6 +94,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -254,6 +255,7 @@ internal class ContractCreateResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -473,6 +475,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -853,6 +856,46 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCommit .RecurrenceFrequency @@ -985,6 +1028,29 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCredit .RecurrenceFrequency @@ -1158,6 +1224,16 @@ internal class ContractCreateResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1192,6 +1268,17 @@ internal class ContractCreateResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty( @@ -1275,6 +1362,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1422,6 +1510,7 @@ internal class ContractCreateResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -1623,6 +1712,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1976,6 +2066,44 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCommit .RecurrenceFrequency @@ -2095,6 +2223,28 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCredit .RecurrenceFrequency @@ -2258,6 +2408,16 @@ internal class ContractCreateResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2290,6 +2450,17 @@ internal class ContractCreateResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2378,6 +2549,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -2538,6 +2710,7 @@ internal class ContractCreateResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2757,6 +2930,7 @@ internal class ContractCreateResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -3137,6 +3311,46 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCommit .RecurrenceFrequency @@ -3269,6 +3483,29 @@ internal class ContractCreateResponseTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCredit .RecurrenceFrequency @@ -3442,6 +3679,16 @@ internal class ContractCreateResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -3476,6 +3723,17 @@ internal class ContractCreateResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty( diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParamsTest.kt new file mode 100644 index 00000000..a98697f0 --- /dev/null +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.metronome.api.models.v1.contracts + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ContractGetSubscriptionSeatsHistoryParamsTest { + + @Test + fun create() { + ContractGetSubscriptionSeatsHistoryParams.builder() + .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d") + .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c") + .coveringDate(OffsetDateTime.parse("2024-01-15T00:00:00.000Z")) + .cursor("cursor") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(10L) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun body() { + val params = + ContractGetSubscriptionSeatsHistoryParams.builder() + .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d") + .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c") + .coveringDate(OffsetDateTime.parse("2024-01-15T00:00:00.000Z")) + .cursor("cursor") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(10L) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.contractId()).isEqualTo("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + assertThat(body.customerId()).isEqualTo("13117714-3f05-48e5-a6e9-a66093f13b4d") + assertThat(body.subscriptionId()).isEqualTo("1a824d53-bde6-4d82-96d7-6347ff227d5c") + assertThat(body.coveringDate()).contains(OffsetDateTime.parse("2024-01-15T00:00:00.000Z")) + assertThat(body.cursor()).contains("cursor") + assertThat(body.endingBefore()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.limit()).contains(10L) + assertThat(body.startingAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ContractGetSubscriptionSeatsHistoryParams.builder() + .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d") + .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c") + .build() + + val body = params._body() + + assertThat(body.contractId()).isEqualTo("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + assertThat(body.customerId()).isEqualTo("13117714-3f05-48e5-a6e9-a66093f13b4d") + assertThat(body.subscriptionId()).isEqualTo("1a824d53-bde6-4d82-96d7-6347ff227d5c") + } +} diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponseTest.kt new file mode 100644 index 00000000..9dbf9427 --- /dev/null +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractGetSubscriptionSeatsHistoryResponseTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.metronome.api.models.v1.contracts + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.metronome.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ContractGetSubscriptionSeatsHistoryResponseTest { + + @Test + fun create() { + val contractGetSubscriptionSeatsHistoryResponse = + ContractGetSubscriptionSeatsHistoryResponse.builder() + .addData( + ContractGetSubscriptionSeatsHistoryResponse.Data.builder() + .addAssignedSeatId("string") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .totalQuantity(0L) + .build() + ) + .nextPage("next_page") + .build() + + assertThat(contractGetSubscriptionSeatsHistoryResponse.data()) + .containsExactly( + ContractGetSubscriptionSeatsHistoryResponse.Data.builder() + .addAssignedSeatId("string") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .totalQuantity(0L) + .build() + ) + assertThat(contractGetSubscriptionSeatsHistoryResponse.nextPage()).contains("next_page") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val contractGetSubscriptionSeatsHistoryResponse = + ContractGetSubscriptionSeatsHistoryResponse.builder() + .addData( + ContractGetSubscriptionSeatsHistoryResponse.Data.builder() + .addAssignedSeatId("string") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .totalQuantity(0L) + .build() + ) + .nextPage("next_page") + .build() + + val roundtrippedContractGetSubscriptionSeatsHistoryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(contractGetSubscriptionSeatsHistoryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedContractGetSubscriptionSeatsHistoryResponse) + .isEqualTo(contractGetSubscriptionSeatsHistoryResponse) + } +} diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesPageResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesPageResponseTest.kt index cd1d27dc..5fe4c62f 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesPageResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesPageResponseTest.kt @@ -65,6 +65,7 @@ internal class ContractListBalancesPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -219,6 +220,7 @@ internal class ContractListBalancesPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -377,6 +379,7 @@ internal class ContractListBalancesPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesResponseTest.kt index 1e667644..7b27b3b9 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListBalancesResponseTest.kt @@ -62,6 +62,7 @@ internal class ContractListBalancesResponseTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -214,6 +215,7 @@ internal class ContractListBalancesResponseTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -366,6 +368,7 @@ internal class ContractListBalancesResponseTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -482,6 +485,7 @@ internal class ContractListBalancesResponseTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListResponseTest.kt index e17f4eec..0ae629f7 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListResponseTest.kt @@ -99,6 +99,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -258,6 +259,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -441,6 +443,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -682,6 +685,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -841,6 +845,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1043,6 +1048,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -1446,6 +1452,44 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -1570,6 +1614,28 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -1847,6 +1913,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -2006,6 +2073,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2208,6 +2276,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -2611,6 +2680,44 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -2735,6 +2842,28 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -3236,6 +3365,15 @@ internal class ContractListResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -3267,6 +3405,17 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3343,6 +3492,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3489,6 +3639,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -3659,6 +3810,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3877,6 +4029,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4023,6 +4176,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -4211,6 +4365,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4581,6 +4736,41 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -4692,6 +4882,26 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -4949,6 +5159,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5095,6 +5306,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -5283,6 +5495,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5653,6 +5866,41 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -5764,6 +6012,26 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -6241,6 +6509,15 @@ internal class ContractListResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -6266,6 +6543,15 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6352,6 +6638,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -6511,6 +6798,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -6694,6 +6982,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -6935,6 +7224,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -7094,6 +7384,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -7296,6 +7587,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -7699,6 +7991,44 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -7823,6 +8153,28 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -8100,6 +8452,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -8259,6 +8612,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -8461,6 +8815,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -8864,6 +9219,44 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -8988,6 +9381,28 @@ internal class ContractListResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -9489,6 +9904,15 @@ internal class ContractListResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -9520,6 +9944,17 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParamsTest.kt index 63891560..90883f6d 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractListSeatBalancesParamsTest.kt @@ -21,6 +21,7 @@ internal class ContractListSeatBalancesParamsTest { .includeLedgers(true) .limit(25L) .addSeatId("string") + .skipMissingSeatIds(true) .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addSubscriptionId("8deed800-1b7a-495d-a207-6c52bac54dc9") .build() @@ -39,6 +40,7 @@ internal class ContractListSeatBalancesParamsTest { .includeLedgers(true) .limit(25L) .addSeatId("string") + .skipMissingSeatIds(true) .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addSubscriptionId("8deed800-1b7a-495d-a207-6c52bac54dc9") .build() @@ -55,6 +57,7 @@ internal class ContractListSeatBalancesParamsTest { assertThat(body.includeLedgers()).contains(true) assertThat(body.limit()).contains(25L) assertThat(body.seatIds().getOrNull()).containsExactly("string") + assertThat(body.skipMissingSeatIds()).contains(true) assertThat(body.startingAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.subscriptionIds().getOrNull()) .containsExactly("8deed800-1b7a-495d-a207-6c52bac54dc9") diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractRetrieveResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractRetrieveResponseTest.kt index 814c695d..6647ffca 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractRetrieveResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/contracts/ContractRetrieveResponseTest.kt @@ -99,6 +99,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -258,6 +259,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -441,6 +443,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -682,6 +685,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -841,6 +845,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1043,6 +1048,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -1446,6 +1452,44 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -1570,6 +1614,28 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -1847,6 +1913,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -2006,6 +2073,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2208,6 +2276,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -2611,6 +2680,44 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -2735,6 +2842,28 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -3236,6 +3365,15 @@ internal class ContractRetrieveResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -3267,6 +3405,17 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3343,6 +3492,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3489,6 +3639,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -3659,6 +3810,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3877,6 +4029,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4023,6 +4176,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -4211,6 +4365,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4581,6 +4736,41 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -4692,6 +4882,26 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -4949,6 +5159,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5095,6 +5306,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency.MONTHLY ) @@ -5283,6 +5495,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5653,6 +5866,41 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -5764,6 +6012,26 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit.ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -6241,6 +6509,15 @@ internal class ContractRetrieveResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode(Subscription.QuantityManagementMode.SEAT_BASED) @@ -6266,6 +6543,15 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6352,6 +6638,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -6511,6 +6798,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -6694,6 +6982,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -6935,6 +7224,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -7094,6 +7384,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -7296,6 +7587,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -7699,6 +7991,44 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -7823,6 +8153,28 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -8100,6 +8452,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -8259,6 +8612,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -8461,6 +8815,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -8864,6 +9219,44 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCommit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractWithoutAmendments.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCommit .RecurrenceFrequency @@ -8988,6 +9381,28 @@ internal class ContractRetrieveResponseTest { .proration( ContractWithoutAmendments.RecurringCredit.Proration.NONE ) + .prorationRounding( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractWithoutAmendments.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractWithoutAmendments + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractWithoutAmendments.RecurringCredit .RecurrenceFrequency @@ -9489,6 +9904,15 @@ internal class ContractRetrieveResponseTest { Subscription.Proration.InvoiceBehavior.BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding.RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -9520,6 +9944,17 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertListPageResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertListPageResponseTest.kt index 775cee16..240d4c5b 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertListPageResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertListPageResponseTest.kt @@ -25,6 +25,42 @@ internal class AlertListPageResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -81,6 +117,40 @@ internal class AlertListPageResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -139,6 +209,42 @@ internal class AlertListPageResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParamsTest.kt index 0e7134c3..9216efba 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveParamsTest.kt @@ -13,6 +13,35 @@ internal class AlertRetrieveParamsTest { AlertRetrieveParams.builder() .alertId("8deed800-1b7a-495d-a207-6c52bac54dc9") .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1") + .addAlertSpecifier( + AlertRetrieveParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.Entity.CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertRetrieveParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addGroupValue( AlertRetrieveParams.GroupValue.builder().key("key").value("value").build() ) @@ -32,6 +61,37 @@ internal class AlertRetrieveParamsTest { AlertRetrieveParams.builder() .alertId("8deed800-1b7a-495d-a207-6c52bac54dc9") .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1") + .addAlertSpecifier( + AlertRetrieveParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertRetrieveParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertRetrieveParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addGroupValue( AlertRetrieveParams.GroupValue.builder().key("key").value("value").build() ) @@ -48,6 +108,36 @@ internal class AlertRetrieveParamsTest { assertThat(body.alertId()).isEqualTo("8deed800-1b7a-495d-a207-6c52bac54dc9") assertThat(body.customerId()).isEqualTo("9b85c1c1-5238-4f2a-a409-61412905e1e1") + assertThat(body.alertSpecifiers().getOrNull()) + .containsExactly( + AlertRetrieveParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.Entity.CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertRetrieveParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) assertThat(body.groupValues().getOrNull()) .containsExactly( AlertRetrieveParams.GroupValue.builder().key("key").value("value").build() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveResponseTest.kt index 03837973..49c1f4d2 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/AlertRetrieveResponseTest.kt @@ -25,6 +25,42 @@ internal class AlertRetrieveResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -80,6 +116,40 @@ internal class AlertRetrieveResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -137,6 +207,42 @@ internal class AlertRetrieveResponseTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier + .Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlertTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlertTest.kt index 1783c6fc..30eaf938 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlertTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/alerts/CustomerAlertTest.kt @@ -23,6 +23,39 @@ internal class CustomerAlertTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter.builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -72,6 +105,37 @@ internal class CustomerAlertTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter.builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() @@ -122,6 +186,39 @@ internal class CustomerAlertTest { .threshold(0.0) .type(CustomerAlert.Alert.Type.LOW_CREDIT_BALANCE_REACHED) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addAlertSpecifier( + CustomerAlert.Alert.AlertSpecifier.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter.builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + CustomerAlert.Alert.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .builder() + .entity( + CustomerAlert.Alert.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addCreditGrantTypeFilter("string") .creditType( CreditTypeData.builder() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/commits/CommitListPageResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/commits/CommitListPageResponseTest.kt index f10afcac..cbb3bde3 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/commits/CommitListPageResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/commits/CommitListPageResponseTest.kt @@ -65,6 +65,7 @@ internal class CommitListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -212,6 +213,7 @@ internal class CommitListPageResponseTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -369,6 +371,7 @@ internal class CommitListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/credits/CreditListPageResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/credits/CreditListPageResponseTest.kt index 9dee1ee3..274cae51 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/credits/CreditListPageResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/credits/CreditListPageResponseTest.kt @@ -61,6 +61,7 @@ internal class CreditListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -175,6 +176,7 @@ internal class CreditListPageResponseTest { .contract( Credit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -299,6 +301,7 @@ internal class CreditListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParamsTest.kt index 88d931fe..ab8a69d2 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/customers/invoices/InvoiceListParamsTest.kt @@ -23,6 +23,7 @@ internal class InvoiceListParamsTest { .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .type(InvoiceListParams.Type.USAGE) + .webhookNotificationId("webhook_notification_id") .build() } @@ -51,6 +52,7 @@ internal class InvoiceListParamsTest { .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .type(InvoiceListParams.Type.USAGE) + .webhookNotificationId("webhook_notification_id") .build() val queryParams = params._queryParams() @@ -68,6 +70,7 @@ internal class InvoiceListParamsTest { .put("starting_on", "2019-12-27T18:11:19.117Z") .put("status", "status") .put("type", "USAGE") + .put("webhook_notification_id", "webhook_notification_id") .build() ) } diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageCreateParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageCreateParamsTest.kt index 14acb1f2..825b6d7e 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageCreateParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageCreateParamsTest.kt @@ -212,6 +212,7 @@ internal class PackageCreateParamsTest { PackageCreateParams.Override.builder() .addOverrideSpecifier( PackageCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( PackageCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -420,6 +421,33 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -494,6 +522,21 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -653,6 +696,16 @@ internal class PackageCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -664,6 +717,14 @@ internal class PackageCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + PackageCreateParams.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageCreateParams.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -917,6 +978,7 @@ internal class PackageCreateParamsTest { PackageCreateParams.Override.builder() .addOverrideSpecifier( PackageCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( PackageCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1141,6 +1203,34 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -1220,6 +1310,22 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -1393,6 +1499,16 @@ internal class PackageCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1405,6 +1521,15 @@ internal class PackageCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + PackageCreateParams.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1660,6 +1785,7 @@ internal class PackageCreateParamsTest { PackageCreateParams.Override.builder() .addOverrideSpecifier( PackageCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( PackageCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1870,6 +1996,33 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -1945,6 +2098,21 @@ internal class PackageCreateParamsTest { ) .name("x") .proration(PackageCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -2107,6 +2275,16 @@ internal class PackageCreateParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2118,6 +2296,14 @@ internal class PackageCreateParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + PackageCreateParams.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageCreateParams.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListPageResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListPageResponseTest.kt index 67f80980..d1b0e3a9 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListPageResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListPageResponseTest.kt @@ -164,6 +164,7 @@ internal class PackageListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier .BillingFrequency @@ -606,6 +607,38 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -703,6 +736,24 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -853,6 +904,18 @@ internal class PackageListPageResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -873,6 +936,15 @@ internal class PackageListPageResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1046,6 +1118,7 @@ internal class PackageListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier .BillingFrequency @@ -1454,6 +1527,37 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -1540,6 +1644,23 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -1676,6 +1797,17 @@ internal class PackageListPageResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1695,6 +1827,15 @@ internal class PackageListPageResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1879,6 +2020,7 @@ internal class PackageListPageResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier .BillingFrequency @@ -2321,6 +2463,38 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -2418,6 +2592,24 @@ internal class PackageListPageResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -2568,6 +2760,18 @@ internal class PackageListPageResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2588,6 +2792,15 @@ internal class PackageListPageResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListResponseTest.kt index 845cb041..92a2d081 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageListResponseTest.kt @@ -150,6 +150,7 @@ internal class PackageListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -543,6 +544,34 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -627,6 +656,22 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -760,6 +805,16 @@ internal class PackageListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -779,6 +834,15 @@ internal class PackageListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -940,6 +1004,7 @@ internal class PackageListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1325,6 +1390,33 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -1405,6 +1497,21 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -1528,6 +1635,16 @@ internal class PackageListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1545,6 +1662,14 @@ internal class PackageListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1709,6 +1834,7 @@ internal class PackageListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageListResponse.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageListResponse.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2102,6 +2228,34 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCommit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageListResponse.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -2186,6 +2340,22 @@ internal class PackageListResponseTest { ) .name("name") .proration(PackageListResponse.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageListResponse.RecurringCredit.ProrationRounding.builder() + .access( + PackageListResponse.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageListResponse.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -2319,6 +2489,16 @@ internal class PackageListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageListResponse.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageListResponse.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2338,6 +2518,15 @@ internal class PackageListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageListResponse.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageListResponse.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageListResponse.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponseTest.kt index 855aaaf0..f9964532 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v1/packages/PackageRetrieveResponseTest.kt @@ -170,6 +170,7 @@ internal class PackageRetrieveResponseTest { .addOverrideSpecifier( PackageRetrieveResponse.Data.Override.OverrideSpecifier .builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageRetrieveResponse.Data.Override.OverrideSpecifier .BillingFrequency @@ -643,6 +644,41 @@ internal class PackageRetrieveResponseTest { .proration( PackageRetrieveResponse.Data.RecurringCommit.Proration.NONE ) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCommit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -757,6 +793,26 @@ internal class PackageRetrieveResponseTest { .proration( PackageRetrieveResponse.Data.RecurringCredit.Proration.NONE ) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCredit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -914,6 +970,20 @@ internal class PackageRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageRetrieveResponse.Data.Subscription.Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.Subscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -937,6 +1007,17 @@ internal class PackageRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageRetrieveResponse.Data.Subscription.BillingCycleConfig + .builder() + .invoicePlacement( + PackageRetrieveResponse.Data.Subscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageRetrieveResponse.Data.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1120,6 +1201,7 @@ internal class PackageRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addOverrideSpecifier( PackageRetrieveResponse.Data.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageRetrieveResponse.Data.Override.OverrideSpecifier .BillingFrequency @@ -1556,6 +1638,41 @@ internal class PackageRetrieveResponseTest { ) .name("name") .proration(PackageRetrieveResponse.Data.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCommit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -1656,6 +1773,26 @@ internal class PackageRetrieveResponseTest { ) .name("name") .proration(PackageRetrieveResponse.Data.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCredit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -1802,6 +1939,18 @@ internal class PackageRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageRetrieveResponse.Data.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1822,6 +1971,16 @@ internal class PackageRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageRetrieveResponse.Data.Subscription.BillingCycleConfig + .builder() + .invoicePlacement( + PackageRetrieveResponse.Data.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageRetrieveResponse.Data.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2016,6 +2175,7 @@ internal class PackageRetrieveResponseTest { .addOverrideSpecifier( PackageRetrieveResponse.Data.Override.OverrideSpecifier .builder() + .addAnyCommitOrCreditTemplateId("string") .billingFrequency( PackageRetrieveResponse.Data.Override.OverrideSpecifier .BillingFrequency @@ -2489,6 +2649,41 @@ internal class PackageRetrieveResponseTest { .proration( PackageRetrieveResponse.Data.RecurringCommit.Proration.NONE ) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCommit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCommit.RecurrenceFrequency .MONTHLY @@ -2603,6 +2798,26 @@ internal class PackageRetrieveResponseTest { .proration( PackageRetrieveResponse.Data.RecurringCredit.Proration.NONE ) + .prorationRounding( + PackageRetrieveResponse.Data.RecurringCredit.ProrationRounding + .builder() + .access( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( PackageRetrieveResponse.Data.RecurringCredit.RecurrenceFrequency .MONTHLY @@ -2760,6 +2975,20 @@ internal class PackageRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageRetrieveResponse.Data.Subscription.Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageRetrieveResponse.Data.Subscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2783,6 +3012,17 @@ internal class PackageRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + PackageRetrieveResponse.Data.Subscription.BillingCycleConfig + .builder() + .invoicePlacement( + PackageRetrieveResponse.Data.Subscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageRetrieveResponse.Data.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditParamsTest.kt index b233f04c..096ba1d1 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditParamsTest.kt @@ -311,6 +311,7 @@ internal class ContractEditParamsTest { .multiplier(2.0) .addOverrideSpecifier( ContractEditParams.AddOverride.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditParams.AddOverride.OverrideSpecifier.BillingFrequency .MONTHLY @@ -527,6 +528,34 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCommit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.AddRecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCommit.RecurrenceFrequency.MONTHLY @@ -608,6 +637,22 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCredit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCredit.RecurrenceFrequency.MONTHLY @@ -842,6 +887,16 @@ internal class ContractEditParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditParams.AddSubscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddSubscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -853,6 +908,16 @@ internal class ContractEditParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractEditParams.AddSubscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractEditParams.AddSubscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditParams.AddSubscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1169,6 +1234,34 @@ internal class ContractEditParamsTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCommit.RateType.LIST_RATE) .build() ) @@ -1182,6 +1275,22 @@ internal class ContractEditParamsTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCredit.RateType.LIST_RATE) .build() ) @@ -1280,6 +1389,16 @@ internal class ContractEditParamsTest { ContractEditParams.UpdateSubscription.builder() .subscriptionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateSubscription.ProrationRounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateSubscription.ProrationRounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .quantityManagementModeUpdate( ContractEditParams.UpdateSubscription.QuantityManagementModeUpdate.builder() .quantityManagementMode( @@ -1670,6 +1789,7 @@ internal class ContractEditParamsTest { .multiplier(2.0) .addOverrideSpecifier( ContractEditParams.AddOverride.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditParams.AddOverride.OverrideSpecifier .BillingFrequency @@ -1905,6 +2025,34 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCommit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.AddRecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCommit.RecurrenceFrequency.MONTHLY @@ -1990,6 +2138,22 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCredit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCredit.RecurrenceFrequency.MONTHLY @@ -2238,6 +2402,16 @@ internal class ContractEditParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditParams.AddSubscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddSubscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2250,6 +2424,16 @@ internal class ContractEditParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractEditParams.AddSubscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractEditParams.AddSubscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditParams.AddSubscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2598,6 +2782,38 @@ internal class ContractEditParamsTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCommit.RateType.LIST_RATE) .build() ) @@ -2611,6 +2827,24 @@ internal class ContractEditParamsTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCredit.RateType.LIST_RATE) .build() ) @@ -2714,6 +2948,16 @@ internal class ContractEditParamsTest { ContractEditParams.UpdateSubscription.builder() .subscriptionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateSubscription.ProrationRounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateSubscription.ProrationRounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .quantityManagementModeUpdate( ContractEditParams.UpdateSubscription.QuantityManagementModeUpdate .builder() @@ -3084,6 +3328,7 @@ internal class ContractEditParamsTest { .multiplier(2.0) .addOverrideSpecifier( ContractEditParams.AddOverride.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditParams.AddOverride.OverrideSpecifier.BillingFrequency .MONTHLY @@ -3303,6 +3548,34 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCommit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.AddRecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCommit.RecurrenceFrequency.MONTHLY @@ -3385,6 +3658,22 @@ internal class ContractEditParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCredit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCredit.RecurrenceFrequency.MONTHLY @@ -3625,6 +3914,16 @@ internal class ContractEditParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditParams.AddSubscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddSubscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -3636,6 +3935,16 @@ internal class ContractEditParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractEditParams.AddSubscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractEditParams.AddSubscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditParams.AddSubscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3961,6 +4270,34 @@ internal class ContractEditParamsTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCommit.RateType.LIST_RATE) .build() ) @@ -3975,6 +4312,22 @@ internal class ContractEditParamsTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCredit.RateType.LIST_RATE) .build() ) @@ -4076,6 +4429,16 @@ internal class ContractEditParamsTest { ContractEditParams.UpdateSubscription.builder() .subscriptionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateSubscription.ProrationRounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateSubscription.ProrationRounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .quantityManagementModeUpdate( ContractEditParams.UpdateSubscription.QuantityManagementModeUpdate.builder() .quantityManagementMode( diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponseTest.kt index 11aaa358..a2e45acc 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractEditResponseTest.kt @@ -319,6 +319,7 @@ internal class ContractEditResponseTest { ContractEditResponse.Data.Edit.AddOverride .OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditResponse.Data.Edit.AddOverride .OverrideSpecifier @@ -655,6 +656,46 @@ internal class ContractEditResponseTest { .Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCommit .RecurrenceFrequency @@ -787,6 +828,29 @@ internal class ContractEditResponseTest { .Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCredit .RecurrenceFrequency @@ -1040,6 +1104,22 @@ internal class ContractEditResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditResponse.Data.Edit.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1085,6 +1165,21 @@ internal class ContractEditResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditResponse.Data.Edit.AddSubscription .CustomFields @@ -1651,6 +1746,46 @@ internal class ContractEditResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCommit .RateType @@ -1672,6 +1807,29 @@ internal class ContractEditResponseTest { .endingBefore( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCredit .RateType @@ -2168,6 +2326,7 @@ internal class ContractEditResponseTest { .addOverrideSpecifier( ContractEditResponse.Data.Edit.AddOverride.OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditResponse.Data.Edit.AddOverride .OverrideSpecifier @@ -2478,6 +2637,44 @@ internal class ContractEditResponseTest { ContractEditResponse.Data.Edit.AddRecurringCommit.Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit.AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit.AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCommit .RecurrenceFrequency @@ -2594,6 +2791,28 @@ internal class ContractEditResponseTest { ContractEditResponse.Data.Edit.AddRecurringCredit.Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit.AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCredit .RecurrenceFrequency @@ -2836,6 +3055,22 @@ internal class ContractEditResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditResponse.Data.Edit.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2879,6 +3114,21 @@ internal class ContractEditResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditResponse.Data.Edit.AddSubscription.CustomFields .builder() @@ -3412,6 +3662,44 @@ internal class ContractEditResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit.UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit.UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCommit .RateType @@ -3431,6 +3719,28 @@ internal class ContractEditResponseTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit.UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCredit .RateType @@ -3936,6 +4246,7 @@ internal class ContractEditResponseTest { ContractEditResponse.Data.Edit.AddOverride .OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditResponse.Data.Edit.AddOverride .OverrideSpecifier @@ -4272,6 +4583,46 @@ internal class ContractEditResponseTest { .Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCommit .RecurrenceFrequency @@ -4404,6 +4755,29 @@ internal class ContractEditResponseTest { .Proration .NONE ) + .prorationRounding( + ContractEditResponse.Data.Edit.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractEditResponse.Data.Edit.AddRecurringCredit .RecurrenceFrequency @@ -4657,6 +5031,22 @@ internal class ContractEditResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditResponse.Data.Edit.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -4702,6 +5092,21 @@ internal class ContractEditResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractEditResponse.Data.Edit.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditResponse.Data.Edit.AddSubscription .CustomFields @@ -5268,6 +5673,46 @@ internal class ContractEditResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCommit .RateType @@ -5289,6 +5734,29 @@ internal class ContractEditResponseTest { .endingBefore( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) + .prorationRounding( + ContractEditResponse.Data.Edit.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractEditResponse.Data.Edit + .UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditResponse.Data.Edit + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractEditResponse.Data.Edit.UpdateRecurringCredit .RateType diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponseTest.kt index a9e96016..6fd43f5c 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractGetEditHistoryResponseTest.kt @@ -283,6 +283,7 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddOverride .OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractGetEditHistoryResponse.Data.AddOverride .OverrideSpecifier @@ -587,6 +588,44 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCommit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCommit .RecurrenceFrequency @@ -702,6 +741,28 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCredit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCredit .RecurrenceFrequency @@ -922,6 +983,22 @@ internal class ContractGetEditHistoryResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractGetEditHistoryResponse.Data.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -965,6 +1042,21 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractGetEditHistoryResponse.Data.AddSubscription.CustomFields .builder() @@ -1465,6 +1557,46 @@ internal class ContractGetEditHistoryResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCommit .RateType @@ -1484,6 +1616,29 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCredit .RateType @@ -1920,6 +2075,7 @@ internal class ContractGetEditHistoryResponseTest { .addOverrideSpecifier( ContractGetEditHistoryResponse.Data.AddOverride.OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractGetEditHistoryResponse.Data.AddOverride .OverrideSpecifier @@ -2207,6 +2363,44 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCommit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCommit .RecurrenceFrequency @@ -2314,6 +2508,28 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCredit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCredit .RecurrenceFrequency @@ -2524,6 +2740,21 @@ internal class ContractGetEditHistoryResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractGetEditHistoryResponse.Data.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data.AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2561,6 +2792,19 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractGetEditHistoryResponse.Data.AddSubscription.CustomFields .builder() @@ -3040,6 +3284,44 @@ internal class ContractGetEditHistoryResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data.UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCommit.RateType .LIST_RATE @@ -3058,6 +3340,28 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCredit.RateType .LIST_RATE @@ -3505,6 +3809,7 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddOverride .OverrideSpecifier .builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractGetEditHistoryResponse.Data.AddOverride .OverrideSpecifier @@ -3809,6 +4114,44 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCommit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data.AddRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCommit .RecurrenceFrequency @@ -3924,6 +4267,28 @@ internal class ContractGetEditHistoryResponseTest { ContractGetEditHistoryResponse.Data.AddRecurringCredit.Proration .NONE ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data.AddRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractGetEditHistoryResponse.Data.AddRecurringCredit .RecurrenceFrequency @@ -4144,6 +4509,22 @@ internal class ContractGetEditHistoryResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractGetEditHistoryResponse.Data.AddSubscription + .Proration + .Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .AddSubscription + .Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -4187,6 +4568,21 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractGetEditHistoryResponse.Data.AddSubscription + .BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractGetEditHistoryResponse.Data.AddSubscription.CustomFields .builder() @@ -4687,6 +5083,46 @@ internal class ContractGetEditHistoryResponseTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCommit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCommit .RateType @@ -4706,6 +5142,29 @@ internal class ContractGetEditHistoryResponseTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractGetEditHistoryResponse.Data.UpdateRecurringCredit + .ProrationRounding + .builder() + .access( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractGetEditHistoryResponse.Data + .UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType( ContractGetEditHistoryResponse.Data.UpdateRecurringCredit .RateType diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractListResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractListResponseTest.kt index 6c908f87..865b1fb1 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractListResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractListResponseTest.kt @@ -77,6 +77,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -213,6 +214,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -389,6 +391,7 @@ internal class ContractListResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -763,6 +766,34 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -861,6 +892,22 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -1076,6 +1123,16 @@ internal class ContractListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1110,6 +1167,18 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1179,6 +1248,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1308,6 +1378,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1478,6 +1549,7 @@ internal class ContractListResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1836,6 +1908,32 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -1925,6 +2023,21 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -2119,6 +2232,16 @@ internal class ContractListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2147,6 +2270,15 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2220,6 +2352,7 @@ internal class ContractListResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2356,6 +2489,7 @@ internal class ContractListResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2532,6 +2666,7 @@ internal class ContractListResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2906,6 +3041,34 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -3004,6 +3167,22 @@ internal class ContractListResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -3219,6 +3398,16 @@ internal class ContractListResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -3253,6 +3442,18 @@ internal class ContractListResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractRetrieveResponseTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractRetrieveResponseTest.kt index ae62f2e1..9fd192df 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractRetrieveResponseTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/models/v2/contracts/ContractRetrieveResponseTest.kt @@ -77,6 +77,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -213,6 +214,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -389,6 +391,7 @@ internal class ContractRetrieveResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -763,6 +766,34 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -861,6 +892,22 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -1076,6 +1123,16 @@ internal class ContractRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1110,6 +1167,18 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1179,6 +1248,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1308,6 +1378,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -1478,6 +1549,7 @@ internal class ContractRetrieveResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1836,6 +1908,32 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -1925,6 +2023,21 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding.Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -2119,6 +2232,16 @@ internal class ContractRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -2147,6 +2270,15 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2220,6 +2352,7 @@ internal class ContractRetrieveResponseTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( ContractV2.Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2356,6 +2489,7 @@ internal class ContractRetrieveResponseTest { .multiplier(0.0) .addOverrideSpecifier( ContractV2.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractV2.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -2532,6 +2666,7 @@ internal class ContractRetrieveResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdBy("created_by") .customFields( ContractV2.Credit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2906,6 +3041,34 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCommit.ProrationRounding.builder() + .access( + ContractV2.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractV2.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCommit.RecurrenceFrequency.MONTHLY ) @@ -3004,6 +3167,22 @@ internal class ContractRetrieveResponseTest { .name("name") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractV2.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractV2.RecurringCredit.ProrationRounding.builder() + .access( + ContractV2.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractV2.RecurringCredit.RecurrenceFrequency.MONTHLY ) @@ -3219,6 +3398,16 @@ internal class ContractRetrieveResponseTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractV2.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractV2.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -3253,6 +3442,18 @@ internal class ContractRetrieveResponseTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + ContractV2.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractV2.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractV2.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/ErrorHandlingTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/ErrorHandlingTest.kt index 5a120db2..6b3a1670 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/ErrorHandlingTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/ErrorHandlingTest.kt @@ -400,6 +400,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -656,6 +657,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -748,6 +781,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -997,6 +1048,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1009,6 +1072,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1412,6 +1487,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -1668,6 +1744,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -1760,6 +1868,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -2009,6 +2135,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -2021,6 +2159,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -2424,6 +2574,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -2680,6 +2831,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -2772,6 +2955,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -3021,6 +3222,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -3033,6 +3246,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -3436,6 +3661,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -3692,6 +3918,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -3784,6 +4042,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -4033,6 +4309,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -4045,6 +4333,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -4448,6 +4748,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -4704,6 +5005,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -4796,6 +5129,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -5045,6 +5396,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -5057,6 +5420,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -5460,6 +5835,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -5716,6 +6092,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -5808,6 +6216,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -6057,6 +6483,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -6069,6 +6507,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -6472,6 +6922,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -6728,6 +7179,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -6820,6 +7303,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -7069,6 +7570,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -7081,6 +7594,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -7484,6 +8009,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -7740,6 +8266,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -7832,6 +8390,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -8081,6 +8657,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -8093,6 +8681,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -8496,6 +9096,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -8752,6 +9353,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -8844,6 +9477,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -9093,6 +9744,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -9105,6 +9768,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -9508,6 +10183,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -9764,6 +10440,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -9856,6 +10564,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -10105,6 +10831,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -10117,6 +10855,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -10520,6 +11270,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -10776,6 +11527,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -10868,6 +11651,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -11117,6 +11918,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -11129,6 +11942,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -11532,6 +12357,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -11788,6 +12614,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -11880,6 +12738,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -12129,6 +13005,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -12141,6 +13029,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -12544,6 +13444,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -12800,6 +13701,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -12892,6 +13825,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -13141,6 +14092,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -13153,6 +14116,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -13556,6 +14531,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -13812,6 +14788,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -13904,6 +14912,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -14153,6 +15179,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -14165,6 +15203,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -14568,6 +15618,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -14824,6 +15875,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -14916,6 +15999,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -15165,6 +16266,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -15177,6 +16290,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -15580,6 +16705,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -15836,6 +16962,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -15928,6 +17086,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -16177,6 +17353,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -16189,6 +17377,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -16590,6 +17790,7 @@ internal class ErrorHandlingTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -16846,6 +18047,38 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -16938,6 +18171,24 @@ internal class ErrorHandlingTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -17187,6 +18438,18 @@ internal class ErrorHandlingTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -17199,6 +18462,18 @@ internal class ErrorHandlingTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/ServiceParamsTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/ServiceParamsTest.kt index 06dd07cc..6dd86889 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/ServiceParamsTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/ServiceParamsTest.kt @@ -344,6 +344,7 @@ internal class ServiceParamsTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -576,6 +577,34 @@ internal class ServiceParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding.Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -660,6 +689,22 @@ internal class ServiceParamsTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -885,6 +930,16 @@ internal class ServiceParamsTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -897,6 +952,16 @@ internal class ServiceParamsTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/AlertServiceAsyncTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/AlertServiceAsyncTest.kt index bbcb0f5d..c30a1417 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/AlertServiceAsyncTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/AlertServiceAsyncTest.kt @@ -27,6 +27,37 @@ internal class AlertServiceAsyncTest { .alertType(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED) .name("\$100 spend threshold reached") .threshold(10000.0) + .addAlertSpecifier( + AlertCreateParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertCreateParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertCreateParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .billableMetricId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCreditGrantTypeFilter("enterprise") .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2") diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncTest.kt index 28dfc1e4..05eb1ea6 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/ContractServiceAsyncTest.kt @@ -19,6 +19,7 @@ import com.metronome.api.models.v1.contracts.ContractArchiveParams import com.metronome.api.models.v1.contracts.ContractCreateHistoricalInvoicesParams import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams import com.metronome.api.models.v1.contracts.ContractListBalancesParams import com.metronome.api.models.v1.contracts.ContractListParams import com.metronome.api.models.v1.contracts.ContractListSeatBalancesParams @@ -349,6 +350,7 @@ internal class ContractServiceAsyncTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -591,6 +593,38 @@ internal class ContractServiceAsyncTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -676,6 +710,24 @@ internal class ContractServiceAsyncTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -908,6 +960,17 @@ internal class ContractServiceAsyncTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -920,6 +983,16 @@ internal class ContractServiceAsyncTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1333,6 +1406,7 @@ internal class ContractServiceAsyncTest { .multiplier(0.0) .addOverrideSpecifier( ContractAmendParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractAmendParams.Override.OverrideSpecifier .BillingFrequency @@ -1654,6 +1728,33 @@ internal class ContractServiceAsyncTest { response.validate() } + @Test + fun getSubscriptionSeatsHistory() { + val client = + MetronomeOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .bearerToken("My Bearer Token") + .build() + val contractServiceAsync = client.v1().contracts() + + val responseFuture = + contractServiceAsync.getSubscriptionSeatsHistory( + ContractGetSubscriptionSeatsHistoryParams.builder() + .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d") + .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c") + .coveringDate(OffsetDateTime.parse("2024-01-15T00:00:00.000Z")) + .cursor("cursor") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(10L) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun listBalances() { val client = @@ -1695,6 +1796,7 @@ internal class ContractServiceAsyncTest { .includeLedgers(true) .limit(25L) .addSeatId("string") + .skipMissingSeatIds(true) .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addSubscriptionId("8deed800-1b7a-495d-a207-6c52bac54dc9") .build() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/PackageServiceAsyncTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/PackageServiceAsyncTest.kt index 07465e08..dd0c5d62 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/PackageServiceAsyncTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/PackageServiceAsyncTest.kt @@ -235,6 +235,7 @@ internal class PackageServiceAsyncTest { PackageCreateParams.Override.builder() .addOverrideSpecifier( PackageCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( PackageCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -470,6 +471,37 @@ internal class PackageServiceAsyncTest { ) .name("x") .proration(PackageCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -551,6 +583,23 @@ internal class PackageServiceAsyncTest { ) .name("x") .proration(PackageCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -727,6 +776,17 @@ internal class PackageServiceAsyncTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -739,6 +799,15 @@ internal class PackageServiceAsyncTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + PackageCreateParams.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsyncTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsyncTest.kt index 7c51d558..3b4e99ab 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsyncTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v1/customers/AlertServiceAsyncTest.kt @@ -27,6 +27,37 @@ internal class AlertServiceAsyncTest { AlertRetrieveParams.builder() .alertId("8deed800-1b7a-495d-a207-6c52bac54dc9") .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1") + .addAlertSpecifier( + AlertRetrieveParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertRetrieveParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertRetrieveParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addGroupValue( AlertRetrieveParams.GroupValue.builder().key("key").value("value").build() ) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v2/ContractServiceAsyncTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v2/ContractServiceAsyncTest.kt index 449f8484..fc45feda 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v2/ContractServiceAsyncTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/async/v2/ContractServiceAsyncTest.kt @@ -418,6 +418,7 @@ internal class ContractServiceAsyncTest { .multiplier(2.0) .addOverrideSpecifier( ContractEditParams.AddOverride.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditParams.AddOverride.OverrideSpecifier .BillingFrequency @@ -657,6 +658,38 @@ internal class ContractServiceAsyncTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCommit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCommit.RecurrenceFrequency.MONTHLY @@ -742,6 +775,24 @@ internal class ContractServiceAsyncTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCredit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCredit.RecurrenceFrequency.MONTHLY @@ -995,6 +1046,18 @@ internal class ContractServiceAsyncTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditParams.AddSubscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddSubscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1007,6 +1070,16 @@ internal class ContractServiceAsyncTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractEditParams.AddSubscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractEditParams.AddSubscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditParams.AddSubscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1365,6 +1438,38 @@ internal class ContractServiceAsyncTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCommit.RateType.LIST_RATE) .build() ) @@ -1378,6 +1483,24 @@ internal class ContractServiceAsyncTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCredit.RateType.LIST_RATE) .build() ) @@ -1485,6 +1608,16 @@ internal class ContractServiceAsyncTest { ContractEditParams.UpdateSubscription.builder() .subscriptionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateSubscription.ProrationRounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateSubscription.ProrationRounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .quantityManagementModeUpdate( ContractEditParams.UpdateSubscription.QuantityManagementModeUpdate .builder() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/AlertServiceTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/AlertServiceTest.kt index 42261a72..c67b061d 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/AlertServiceTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/AlertServiceTest.kt @@ -27,6 +27,37 @@ internal class AlertServiceTest { .alertType(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED) .name("\$100 spend threshold reached") .threshold(10000.0) + .addAlertSpecifier( + AlertCreateParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertCreateParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertCreateParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertCreateParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertCreateParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .billableMetricId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCreditGrantTypeFilter("enterprise") .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2") diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/ContractServiceTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/ContractServiceTest.kt index f064af1c..970b4e54 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/ContractServiceTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/ContractServiceTest.kt @@ -19,6 +19,7 @@ import com.metronome.api.models.v1.contracts.ContractArchiveParams import com.metronome.api.models.v1.contracts.ContractCreateHistoricalInvoicesParams import com.metronome.api.models.v1.contracts.ContractCreateParams import com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams +import com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams import com.metronome.api.models.v1.contracts.ContractListBalancesParams import com.metronome.api.models.v1.contracts.ContractListParams import com.metronome.api.models.v1.contracts.ContractListSeatBalancesParams @@ -349,6 +350,7 @@ internal class ContractServiceTest { .multiplier(0.0) .addOverrideSpecifier( ContractCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -591,6 +593,38 @@ internal class ContractServiceTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -676,6 +710,24 @@ internal class ContractServiceTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + ContractCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + ContractCreateParams.RecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -908,6 +960,17 @@ internal class ContractServiceTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -920,6 +983,16 @@ internal class ContractServiceTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractCreateParams.Subscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1327,6 +1400,7 @@ internal class ContractServiceTest { .multiplier(0.0) .addOverrideSpecifier( ContractAmendParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractAmendParams.Override.OverrideSpecifier .BillingFrequency @@ -1644,6 +1718,32 @@ internal class ContractServiceTest { response.validate() } + @Test + fun getSubscriptionSeatsHistory() { + val client = + MetronomeOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .bearerToken("My Bearer Token") + .build() + val contractService = client.v1().contracts() + + val response = + contractService.getSubscriptionSeatsHistory( + ContractGetSubscriptionSeatsHistoryParams.builder() + .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc") + .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d") + .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c") + .coveringDate(OffsetDateTime.parse("2024-01-15T00:00:00.000Z")) + .cursor("cursor") + .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .limit(10L) + .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } + @Test fun listBalances() { val client = @@ -1684,6 +1784,7 @@ internal class ContractServiceTest { .includeLedgers(true) .limit(25L) .addSeatId("string") + .skipMissingSeatIds(true) .startingAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addSubscriptionId("8deed800-1b7a-495d-a207-6c52bac54dc9") .build() diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/PackageServiceTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/PackageServiceTest.kt index 978397e7..158d15ff 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/PackageServiceTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/PackageServiceTest.kt @@ -235,6 +235,7 @@ internal class PackageServiceTest { PackageCreateParams.Override.builder() .addOverrideSpecifier( PackageCreateParams.Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( PackageCreateParams.Override.OverrideSpecifier .BillingFrequency @@ -470,6 +471,37 @@ internal class PackageServiceTest { ) .name("x") .proration(PackageCreateParams.RecurringCommit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCommit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCommit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + PackageCreateParams.RecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCommit.RecurrenceFrequency.MONTHLY @@ -551,6 +583,23 @@ internal class PackageServiceTest { ) .name("x") .proration(PackageCreateParams.RecurringCredit.Proration.NONE) + .prorationRounding( + PackageCreateParams.RecurringCredit.ProrationRounding.builder() + .access( + PackageCreateParams.RecurringCredit.ProrationRounding.Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(PackageCreateParams.RecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( PackageCreateParams.RecurringCredit.RecurrenceFrequency.MONTHLY @@ -727,6 +776,17 @@ internal class PackageServiceTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + PackageCreateParams.Subscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + PackageCreateParams.Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -739,6 +799,15 @@ internal class PackageServiceTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + PackageCreateParams.Subscription.BillingCycleConfig.builder() + .invoicePlacement( + PackageCreateParams.Subscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( PackageCreateParams.Subscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/customers/AlertServiceTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/customers/AlertServiceTest.kt index 9fd3dab3..033715a8 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/customers/AlertServiceTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v1/customers/AlertServiceTest.kt @@ -27,6 +27,37 @@ internal class AlertServiceTest { AlertRetrieveParams.builder() .alertId("8deed800-1b7a-495d-a207-6c52bac54dc9") .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1") + .addAlertSpecifier( + AlertRetrieveParams.AlertSpecifier.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.builder() + .entity( + AlertRetrieveParams.AlertSpecifier.CustomFieldFilter.Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .addExclude( + AlertRetrieveParams.AlertSpecifier.Exclude.builder() + .addCustomFieldFilter( + AlertRetrieveParams.AlertSpecifier.Exclude.CustomFieldFilter + .builder() + .entity( + AlertRetrieveParams.AlertSpecifier.Exclude + .CustomFieldFilter + .Entity + .CONTRACT + ) + .key("key") + .value("value") + .build() + ) + .build() + ) + .build() + ) .addGroupValue( AlertRetrieveParams.GroupValue.builder().key("key").value("value").build() ) diff --git a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v2/ContractServiceTest.kt b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v2/ContractServiceTest.kt index 22ed8b17..94386d20 100644 --- a/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v2/ContractServiceTest.kt +++ b/metronome-java-core/src/test/kotlin/com/metronome/api/services/blocking/v2/ContractServiceTest.kt @@ -416,6 +416,7 @@ internal class ContractServiceTest { .multiplier(2.0) .addOverrideSpecifier( ContractEditParams.AddOverride.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( ContractEditParams.AddOverride.OverrideSpecifier .BillingFrequency @@ -655,6 +656,38 @@ internal class ContractServiceTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCommit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.AddRecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCommit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCommit.RecurrenceFrequency.MONTHLY @@ -740,6 +773,24 @@ internal class ContractServiceTest { .name("x") .netsuiteSalesOrderId("netsuite_sales_order_id") .proration(ContractEditParams.AddRecurringCredit.Proration.NONE) + .prorationRounding( + ContractEditParams.AddRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.AddRecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.AddRecurringCredit.RateType.COMMIT_RATE) .recurrenceFrequency( ContractEditParams.AddRecurringCredit.RecurrenceFrequency.MONTHLY @@ -993,6 +1044,18 @@ internal class ContractServiceTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + ContractEditParams.AddSubscription.Proration.Rounding + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.AddSubscription.Proration + .Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .subscriptionRate( @@ -1005,6 +1068,16 @@ internal class ContractServiceTest { .productId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .billingCycleConfig( + ContractEditParams.AddSubscription.BillingCycleConfig.builder() + .anchorDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoicePlacement( + ContractEditParams.AddSubscription.BillingCycleConfig + .InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( ContractEditParams.AddSubscription.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1363,6 +1436,38 @@ internal class ContractServiceTest { .unitPrice(0.0) .build() ) + .prorationRounding( + ContractEditParams.UpdateRecurringCommit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractEditParams.UpdateRecurringCommit.ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCommit.RateType.LIST_RATE) .build() ) @@ -1376,6 +1481,24 @@ internal class ContractServiceTest { .build() ) .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateRecurringCredit.ProrationRounding.builder() + .access( + ContractEditParams.UpdateRecurringCredit.ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateRecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .rateType(ContractEditParams.UpdateRecurringCredit.RateType.LIST_RATE) .build() ) @@ -1483,6 +1606,16 @@ internal class ContractServiceTest { ContractEditParams.UpdateSubscription.builder() .subscriptionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .prorationRounding( + ContractEditParams.UpdateSubscription.ProrationRounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractEditParams.UpdateSubscription.ProrationRounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .quantityManagementModeUpdate( ContractEditParams.UpdateSubscription.QuantityManagementModeUpdate .builder() diff --git a/metronome-java-proguard-test/src/test/kotlin/com/metronome/api/proguard/ProGuardCompatibilityTest.kt b/metronome-java-proguard-test/src/test/kotlin/com/metronome/api/proguard/ProGuardCompatibilityTest.kt index 47a68496..dafa3ffb 100644 --- a/metronome-java-proguard-test/src/test/kotlin/com/metronome/api/proguard/ProGuardCompatibilityTest.kt +++ b/metronome-java-proguard-test/src/test/kotlin/com/metronome/api/proguard/ProGuardCompatibilityTest.kt @@ -138,6 +138,7 @@ internal class ProGuardCompatibilityTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty( @@ -298,6 +299,7 @@ internal class ProGuardCompatibilityTest { .multiplier(0.0) .addOverrideSpecifier( Override.OverrideSpecifier.builder() + .addAnyCommitOrCreditId("string") .billingFrequency( Override.OverrideSpecifier.BillingFrequency .MONTHLY @@ -517,6 +519,7 @@ internal class ProGuardCompatibilityTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) + .createdBy("created_by") .customFields( Credit.CustomFields.builder() .putAdditionalProperty( @@ -897,6 +900,46 @@ internal class ProGuardCompatibilityTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCommit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .invoice( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCommit + .ProrationRounding + .Invoice + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCommit .RecurrenceFrequency @@ -1029,6 +1072,29 @@ internal class ProGuardCompatibilityTest { .Proration .NONE ) + .prorationRounding( + ContractCreateResponse.Data.Contract.RecurringCredit + .ProrationRounding + .builder() + .access( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .builder() + .decimalPlaces(-5.0) + .roundingMethod( + ContractCreateResponse.Data.Contract + .RecurringCredit + .ProrationRounding + .Access + .RoundingMethod + .HALF_UP + ) + .build() + ) + .build() + ) .recurrenceFrequency( ContractCreateResponse.Data.Contract.RecurringCredit .RecurrenceFrequency @@ -1202,6 +1268,16 @@ internal class ProGuardCompatibilityTest { .BILL_IMMEDIATELY ) .isProrated(true) + .rounding( + Subscription.Proration.Rounding.builder() + .decimalPlaces(-5.0) + .roundingMethod( + Subscription.Proration.Rounding + .RoundingMethod + .HALF_UP + ) + .build() + ) .build() ) .quantityManagementMode( @@ -1236,6 +1312,17 @@ internal class ProGuardCompatibilityTest { .build() ) .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingCycleConfig( + Subscription.BillingCycleConfig.builder() + .anchorDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .invoicePlacement( + Subscription.BillingCycleConfig.InvoicePlacement + .ON_SCHEDULED_INVOICE + ) + .build() + ) .customFields( Subscription.CustomFields.builder() .putAdditionalProperty( @@ -1315,6 +1402,7 @@ internal class ProGuardCompatibilityTest { .contract( Commit.Contract.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) + .createdBy("created_by") .customFields( Commit.CustomFields.builder() .putAdditionalProperty("foo", JsonValue.from("string"))