diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 21fa4455..d940b600 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.54.0" + ".": "0.55.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 1e64c91b..88277273 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-95a3d7780935a38e0cf076d4ad2d68bd1a5641bced8398d972db2e92751d364a.yml -openapi_spec_hash: 9ebe818c4ad4f2d9c4e473b5192d7544 -config_hash: 54edf41f0377bc235f622fdaa7405f22 +configured_endpoints: 106 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-e8dad7eee5621fe2ba948dfd00dabf170d9d92ce615a9f04b0f546f4d8bf39ba.yml +openapi_spec_hash: 3f6a98e3a1b3a47acebd67a960090ebf +config_hash: 7e523cf79552b8936bd772f2e1025e5f diff --git a/CHANGELOG.md b/CHANGELOG.md index ab22053d..51e113d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.55.0 (2025-04-08) + +Full Changelog: [v0.54.0...v0.55.0](https://github.com/orbcorp/orb-java/compare/v0.54.0...v0.55.0) + +### Features + +* **api:** api update ([#391](https://github.com/orbcorp/orb-java/issues/391)) ([7d1978f](https://github.com/orbcorp/orb-java/commit/7d1978fec3bc01cb0a02fff2433dcf4077469f58)) + + +### Chores + +* **internal:** codegen related update ([#393](https://github.com/orbcorp/orb-java/issues/393)) ([e941542](https://github.com/orbcorp/orb-java/commit/e941542e549401f37058816a428e6d334fa57d01)) +* **tests:** improve enum examples ([#394](https://github.com/orbcorp/orb-java/issues/394)) ([f1c810a](https://github.com/orbcorp/orb-java/commit/f1c810a7fd6a67722803f9baa6182a32d0644f1f)) + ## 0.54.0 (2025-04-07) Full Changelog: [v0.53.0...v0.54.0](https://github.com/orbcorp/orb-java/compare/v0.53.0...v0.54.0) diff --git a/README.md b/README.md index 3c4906c4..9eb20414 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.54.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.55.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:0.54.0") +implementation("com.withorb.api:orb-java:0.55.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.54.0") com.withorb.api orb-java - 0.54.0 + 0.55.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 760b2f73..f2cb58af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "com.withorb.api" - version = "0.54.0" // x-release-please-version + version = "0.55.0" // x-release-please-version } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt index a35901a5..5151c17e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt @@ -14,6 +14,7 @@ import com.withorb.api.services.blocking.ItemService import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.PlanService import com.withorb.api.services.blocking.PriceService +import com.withorb.api.services.blocking.SubscriptionChangeService import com.withorb.api.services.blocking.SubscriptionService import com.withorb.api.services.blocking.TopLevelService import com.withorb.api.services.blocking.WebhookService @@ -77,6 +78,8 @@ interface OrbClient { fun dimensionalPriceGroups(): DimensionalPriceGroupService + fun subscriptionChanges(): SubscriptionChangeService + /** * Closes this client, relinquishing any underlying resources. * @@ -120,5 +123,7 @@ interface OrbClient { fun alerts(): AlertService.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse + + fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt index 20b04b5c..c4723762 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt @@ -14,6 +14,7 @@ import com.withorb.api.services.async.ItemServiceAsync import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.PlanServiceAsync import com.withorb.api.services.async.PriceServiceAsync +import com.withorb.api.services.async.SubscriptionChangeServiceAsync import com.withorb.api.services.async.SubscriptionServiceAsync import com.withorb.api.services.async.TopLevelServiceAsync @@ -74,6 +75,8 @@ interface OrbClientAsync { fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync + fun subscriptionChanges(): SubscriptionChangeServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -117,5 +120,7 @@ interface OrbClientAsync { fun alerts(): AlertServiceAsync.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse + + fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index c74456d9..dffa5fe3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -28,6 +28,8 @@ import com.withorb.api.services.async.PlanServiceAsync import com.withorb.api.services.async.PlanServiceAsyncImpl import com.withorb.api.services.async.PriceServiceAsync import com.withorb.api.services.async.PriceServiceAsyncImpl +import com.withorb.api.services.async.SubscriptionChangeServiceAsync +import com.withorb.api.services.async.SubscriptionChangeServiceAsyncImpl import com.withorb.api.services.async.SubscriptionServiceAsync import com.withorb.api.services.async.SubscriptionServiceAsyncImpl import com.withorb.api.services.async.TopLevelServiceAsync @@ -102,6 +104,10 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs DimensionalPriceGroupServiceAsyncImpl(clientOptionsWithUserAgent) } + private val subscriptionChanges: SubscriptionChangeServiceAsync by lazy { + SubscriptionChangeServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): OrbClient = sync override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse @@ -135,6 +141,8 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync = dimensionalPriceGroups + override fun subscriptionChanges(): SubscriptionChangeServiceAsync = subscriptionChanges + override fun close() = clientOptions.httpClient.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -197,6 +205,10 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs DimensionalPriceGroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val subscriptionChanges: SubscriptionChangeServiceAsync.WithRawResponse by lazy { + SubscriptionChangeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel override fun coupons(): CouponServiceAsync.WithRawResponse = coupons @@ -226,5 +238,8 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse = dimensionalPriceGroups + + override fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse = + subscriptionChanges } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index 1c5d79f4..361ec509 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -28,6 +28,8 @@ import com.withorb.api.services.blocking.PlanService import com.withorb.api.services.blocking.PlanServiceImpl import com.withorb.api.services.blocking.PriceService import com.withorb.api.services.blocking.PriceServiceImpl +import com.withorb.api.services.blocking.SubscriptionChangeService +import com.withorb.api.services.blocking.SubscriptionChangeServiceImpl import com.withorb.api.services.blocking.SubscriptionService import com.withorb.api.services.blocking.SubscriptionServiceImpl import com.withorb.api.services.blocking.TopLevelService @@ -94,6 +96,10 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptions) } + private val subscriptionChanges: SubscriptionChangeService by lazy { + SubscriptionChangeServiceImpl(clientOptionsWithUserAgent) + } + override fun async(): OrbClientAsync = async override fun withRawResponse(): OrbClient.WithRawResponse = withRawResponse @@ -128,6 +134,8 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups + override fun subscriptionChanges(): SubscriptionChangeService = subscriptionChanges + override fun close() = clientOptions.httpClient.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -189,6 +197,10 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { DimensionalPriceGroupServiceImpl.WithRawResponseImpl(clientOptions) } + private val subscriptionChanges: SubscriptionChangeService.WithRawResponse by lazy { + SubscriptionChangeServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun topLevel(): TopLevelService.WithRawResponse = topLevel override fun coupons(): CouponService.WithRawResponse = coupons @@ -217,5 +229,8 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse = dimensionalPriceGroups + + override fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse = + subscriptionChanges } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 8d475a34..ce484275 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -351,7 +351,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1068,7 +1068,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -2968,7 +2968,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index e17c37dc..c6d81bff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -254,7 +254,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -934,7 +934,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1444,7 +1444,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -2198,7 +2198,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -5072,7 +5072,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 49049f7e..abdb287c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -251,7 +251,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -925,7 +925,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1421,7 +1421,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -2155,7 +2155,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -5002,7 +5002,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 92a26469..5e40f2bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -252,7 +252,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -923,7 +923,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1419,7 +1419,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -2151,7 +2151,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -4998,7 +4998,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 48c89237..6af774be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -368,7 +368,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1371,7 +1371,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -4719,7 +4719,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 1db25b6e..0a231fd9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -111,8 +111,8 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * When true, this invoice will automatically be issued upon creation. When false, the resulting - * invoice will require manual review to issue. Defaulted to false. + * When true, this invoice will be submitted for issuance upon creation. When false, the + * resulting invoice will require manual review to issue. Defaulted to false. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -422,7 +422,7 @@ private constructor( fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** - * When true, this invoice will automatically be issued upon creation. When false, the + * When true, this invoice will be submitted for issuance upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ fun willAutoIssue(willAutoIssue: Boolean) = apply { body.willAutoIssue(willAutoIssue) } @@ -720,7 +720,7 @@ private constructor( fun metadata(): Optional = metadata.getOptional("metadata") /** - * When true, this invoice will automatically be issued upon creation. When false, the + * When true, this invoice will be submitted for issuance upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1065,7 +1065,7 @@ private constructor( fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * When true, this invoice will automatically be issued upon creation. When false, the + * When true, this invoice will be submitted for issuance upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index f42c44b2..c45d7264 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -361,7 +361,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -1365,7 +1365,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | @@ -4710,7 +4710,7 @@ private constructor( * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 8864f36f..de56dcf2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -10582,7 +10582,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -10600,7 +10600,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -10680,7 +10680,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -10709,7 +10709,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier */ fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) @@ -13038,7 +13038,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -13047,7 +13047,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -13159,7 +13159,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -13174,7 +13174,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt index aa281bf9..6aa20c66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -16463,7 +16463,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -16481,7 +16481,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -16560,7 +16560,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -16588,7 +16588,7 @@ private constructor( this.unitAmount = unitAmount } - /** Exclusive tier ending value. If null, this is treated as the last tier */ + /** Inclusive tier ending value. If null, this is treated as the last tier */ fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) /** @@ -20566,7 +20566,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -20575,7 +20575,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -20684,7 +20684,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -20699,7 +20699,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index d3660f9f..e9b9c86e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -12601,7 +12601,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -12619,7 +12619,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -12699,7 +12699,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -12728,7 +12728,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier */ fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) @@ -15055,7 +15055,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -15064,7 +15064,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -15176,7 +15176,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -15191,7 +15191,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index 0ad51203..94fc2b50 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -69,6 +69,7 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, @@ -130,6 +131,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -164,6 +168,7 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, @@ -355,6 +360,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -573,6 +587,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -659,6 +684,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -694,6 +720,7 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null @@ -724,6 +751,7 @@ private constructor( metadata = subscription.metadata minimumIntervals = subscription.minimumIntervals.map { it.toMutableList() } netTerms = subscription.netTerms + pendingSubscriptionChange = subscription.pendingSubscriptionChange plan = subscription.plan priceIntervals = subscription.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscription.redeemedCoupon @@ -1174,6 +1202,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1312,6 +1363,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1345,6 +1397,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), @@ -1381,6 +1434,7 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } @@ -1424,6 +1478,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + @@ -8516,6 +8571,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10105,15 +10317,15 @@ private constructor( return true } - return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Subscription{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "Subscription{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt index 1e1202ec..b1147de0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -642,6 +693,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -677,12 +729,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -712,12 +766,14 @@ private constructor( minimumIntervals = subscriptionCancelResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionCancelResponse.netTerms + pendingSubscriptionChange = subscriptionCancelResponse.pendingSubscriptionChange plan = subscriptionCancelResponse.plan priceIntervals = subscriptionCancelResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionCancelResponse.redeemedCoupon startDate = subscriptionCancelResponse.startDate status = subscriptionCancelResponse.status trialInfo = subscriptionCancelResponse.trialInfo + changedResources = subscriptionCancelResponse.changedResources additionalProperties = subscriptionCancelResponse.additionalProperties.toMutableMap() } @@ -1162,6 +1218,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1255,6 +1334,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1300,6 +1402,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1333,12 +1436,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1369,12 +1474,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1412,12 +1519,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8504,6 +8613,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10088,20 +10354,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionCancelResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionCancelResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionCancelResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionCancelResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt new file mode 100644 index 00000000..986120fa --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -0,0 +1,522 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Apply a subscription change to perform the intended action. If a positive amount is passed with a + * request to this endpoint, any eligible invoices that were created will be issued immediately if + * they only contain in-advance fees. + */ +class SubscriptionChangeApplyParams +private constructor( + private val subscriptionChangeId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun subscriptionChangeId(): String = subscriptionChangeId + + /** + * Description to apply to the balance transaction representing this credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * Amount already collected to apply to the customer's balance. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun previouslyCollectedAmount(): Optional = body.previouslyCollectedAmount() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [previouslyCollectedAmount]. + * + * Unlike [previouslyCollectedAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _previouslyCollectedAmount(): JsonField = body._previouslyCollectedAmount() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeApplyParams]. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeApplyParams]. */ + class Builder internal constructor() { + + private var subscriptionChangeId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionChangeApplyParams: SubscriptionChangeApplyParams) = apply { + subscriptionChangeId = subscriptionChangeApplyParams.subscriptionChangeId + body = subscriptionChangeApplyParams.body.toBuilder() + additionalHeaders = subscriptionChangeApplyParams.additionalHeaders.toBuilder() + additionalQueryParams = subscriptionChangeApplyParams.additionalQueryParams.toBuilder() + } + + fun subscriptionChangeId(subscriptionChangeId: String) = apply { + this.subscriptionChangeId = subscriptionChangeId + } + + /** + * 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: + * - [description] + * - [previouslyCollectedAmount] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Description to apply to the balance transaction representing this credit. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** Amount already collected to apply to the customer's balance. */ + fun previouslyCollectedAmount(previouslyCollectedAmount: String?) = apply { + body.previouslyCollectedAmount(previouslyCollectedAmount) + } + + /** + * Alias for calling [Builder.previouslyCollectedAmount] with + * `previouslyCollectedAmount.orElse(null)`. + */ + fun previouslyCollectedAmount(previouslyCollectedAmount: Optional) = + previouslyCollectedAmount(previouslyCollectedAmount.getOrNull()) + + /** + * Sets [Builder.previouslyCollectedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyCollectedAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun previouslyCollectedAmount(previouslyCollectedAmount: JsonField) = apply { + body.previouslyCollectedAmount(previouslyCollectedAmount) + } + + 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 [SubscriptionChangeApplyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeApplyParams = + SubscriptionChangeApplyParams( + checkRequired("subscriptionChangeId", subscriptionChangeId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> subscriptionChangeId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val description: JsonField, + private val previouslyCollectedAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("previously_collected_amount") + @ExcludeMissing + previouslyCollectedAmount: JsonField = JsonMissing.of(), + ) : this(description, previouslyCollectedAmount, mutableMapOf()) + + /** + * Description to apply to the balance transaction representing this credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Amount already collected to apply to the customer's balance. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previouslyCollectedAmount(): Optional = + previouslyCollectedAmount.getOptional("previously_collected_amount") + + /** + * 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 [previouslyCollectedAmount]. + * + * Unlike [previouslyCollectedAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previously_collected_amount") + @ExcludeMissing + fun _previouslyCollectedAmount(): JsonField = previouslyCollectedAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var previouslyCollectedAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + previouslyCollectedAmount = body.previouslyCollectedAmount + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Description to apply to the balance transaction representing this credit. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Amount already collected to apply to the customer's balance. */ + fun previouslyCollectedAmount(previouslyCollectedAmount: String?) = + previouslyCollectedAmount(JsonField.ofNullable(previouslyCollectedAmount)) + + /** + * Alias for calling [Builder.previouslyCollectedAmount] with + * `previouslyCollectedAmount.orElse(null)`. + */ + fun previouslyCollectedAmount(previouslyCollectedAmount: Optional) = + previouslyCollectedAmount(previouslyCollectedAmount.getOrNull()) + + /** + * Sets [Builder.previouslyCollectedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyCollectedAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previouslyCollectedAmount(previouslyCollectedAmount: JsonField) = apply { + this.previouslyCollectedAmount = previouslyCollectedAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(description, previouslyCollectedAmount, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + previouslyCollectedAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (previouslyCollectedAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && description == other.description && previouslyCollectedAmount == other.previouslyCollectedAmount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(description, previouslyCollectedAmount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, previouslyCollectedAmount=$previouslyCollectedAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeApplyParams && subscriptionChangeId == other.subscriptionChangeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SubscriptionChangeApplyParams{subscriptionChangeId=$subscriptionChangeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt new file mode 100644 index 00000000..4943568e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt @@ -0,0 +1,11498 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A subscription change represents a desired new subscription / pending change to an existing + * subscription. It is a way to first preview the effects on the subscription as well as any + * changes/creation of invoices (see `subscription.changed_resources`). + */ +class SubscriptionChangeApplyResponse +private constructor( + private val id: JsonField, + private val expirationTime: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val appliedAt: JsonField, + private val cancelledAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("expiration_time") + @ExcludeMissing + expirationTime: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("applied_at") + @ExcludeMissing + appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("cancelled_at") + @ExcludeMissing + cancelledAt: JsonField = JsonMissing.of(), + ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Subscription change will be cancelled at this time and can no longer be applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun expirationTime(): OffsetDateTime = expirationTime.getRequired("expiration_time") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): Optional = subscription.getOptional("subscription") + + /** + * When this change was applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun appliedAt(): Optional = appliedAt.getOptional("applied_at") + + /** + * When this change was cancelled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun cancelledAt(): Optional = cancelledAt.getOptional("cancelled_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 [expirationTime]. + * + * Unlike [expirationTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiration_time") + @ExcludeMissing + fun _expirationTime(): JsonField = expirationTime + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [appliedAt]. + * + * Unlike [appliedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("applied_at") + @ExcludeMissing + fun _appliedAt(): JsonField = appliedAt + + /** + * Returns the raw JSON value of [cancelledAt]. + * + * Unlike [cancelledAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cancelled_at") + @ExcludeMissing + fun _cancelledAt(): JsonField = cancelledAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeApplyResponse]. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeApplyResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var expirationTime: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var appliedAt: JsonField = JsonMissing.of() + private var cancelledAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionChangeApplyResponse: SubscriptionChangeApplyResponse) = + apply { + id = subscriptionChangeApplyResponse.id + expirationTime = subscriptionChangeApplyResponse.expirationTime + status = subscriptionChangeApplyResponse.status + subscription = subscriptionChangeApplyResponse.subscription + appliedAt = subscriptionChangeApplyResponse.appliedAt + cancelledAt = subscriptionChangeApplyResponse.cancelledAt + additionalProperties = + subscriptionChangeApplyResponse.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 } + + /** Subscription change will be cancelled at this time and can no longer be applied. */ + fun expirationTime(expirationTime: OffsetDateTime) = + expirationTime(JsonField.of(expirationTime)) + + /** + * Sets [Builder.expirationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.expirationTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expirationTime(expirationTime: JsonField) = apply { + this.expirationTime = expirationTime + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [Subscription] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** When this change was applied. */ + fun appliedAt(appliedAt: OffsetDateTime?) = appliedAt(JsonField.ofNullable(appliedAt)) + + /** Alias for calling [Builder.appliedAt] with `appliedAt.orElse(null)`. */ + fun appliedAt(appliedAt: Optional) = appliedAt(appliedAt.getOrNull()) + + /** + * Sets [Builder.appliedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.appliedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + + /** When this change was cancelled. */ + fun cancelledAt(cancelledAt: OffsetDateTime?) = + cancelledAt(JsonField.ofNullable(cancelledAt)) + + /** Alias for calling [Builder.cancelledAt] with `cancelledAt.orElse(null)`. */ + fun cancelledAt(cancelledAt: Optional) = + cancelledAt(cancelledAt.getOrNull()) + + /** + * Sets [Builder.cancelledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.cancelledAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancelledAt(cancelledAt: JsonField) = apply { + this.cancelledAt = cancelledAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionChangeApplyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeApplyResponse = + SubscriptionChangeApplyResponse( + checkRequired("id", id), + checkRequired("expirationTime", expirationTime), + checkRequired("status", status), + checkRequired("subscription", subscription), + appliedAt, + cancelledAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubscriptionChangeApplyResponse = apply { + if (validated) { + return@apply + } + + id() + expirationTime() + status().validate() + subscription().ifPresent { it.validate() } + appliedAt() + cancelledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (expirationTime.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (appliedAt.asKnown().isPresent) 1 else 0) + + (if (cancelledAt.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val APPLIED = of("applied") + + @JvmField val CANCELLED = of("cancelled") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + APPLIED, + CANCELLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + APPLIED, + CANCELLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + APPLIED -> Value.APPLIED + CANCELLED -> Value.CANCELLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + APPLIED -> Known.APPLIED + CANCELLED -> Known.CANCELLED + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Subscription + private constructor( + private val id: JsonField, + private val activePlanPhaseOrder: JsonField, + private val adjustmentIntervals: JsonField>, + private val autoCollection: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val billingCycleDay: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val customer: JsonField, + private val defaultInvoiceMemo: JsonField, + private val discountIntervals: JsonField>, + private val endDate: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val invoicingThreshold: JsonField, + private val maximumIntervals: JsonField>, + private val metadata: JsonField, + private val minimumIntervals: JsonField>, + private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, + private val plan: JsonField, + private val priceIntervals: JsonField>, + private val redeemedCoupon: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val changedResources: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + activePlanPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_intervals") + @ExcludeMissing + adjustmentIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("discount_intervals") + @ExcludeMissing + discountIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fixedFeeQuantitySchedule: JsonField> = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("maximum_intervals") + @ExcludeMissing + maximumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum_intervals") + @ExcludeMissing + minimumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), + @JsonProperty("price_intervals") + @ExcludeMissing + priceIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("redeemed_coupon") + @ExcludeMissing + redeemedCoupon: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("trial_info") + @ExcludeMissing + trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), + ) : this( + id, + activePlanPhaseOrder, + adjustmentIntervals, + autoCollection, + billingCycleAnchorConfiguration, + billingCycleDay, + createdAt, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + customer, + defaultInvoiceMemo, + discountIntervals, + endDate, + fixedFeeQuantitySchedule, + invoicingThreshold, + maximumIntervals, + metadata, + minimumIntervals, + netTerms, + pendingSubscriptionChange, + plan, + priceIntervals, + redeemedCoupon, + startDate, + status, + trialInfo, + changedResources, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The current plan phase that is active, only if the subscription's plan has phases. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun activePlanPhaseOrder(): Optional = + activePlanPhaseOrder.getOptional("active_plan_phase_order") + + /** + * The adjustment intervals for this subscription sorted by the start_date of the adjustment + * interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultInvoiceMemo(): Optional = + defaultInvoiceMemo.getOptional("default_invoice_memo") + + /** + * The discount intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** + * The date Orb stops billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingThreshold(): Optional = + invoicingThreshold.getOptional("invoicing_threshold") + + /** + * The maximum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maximumIntervals(): List = + maximumIntervals.getRequired("maximum_intervals") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * The minimum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun plan(): Plan = plan.getRequired("plan") + + /** + * The price intervals for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun redeemedCoupon(): Optional = + redeemedCoupon.getOptional("redeemed_coupon") + + /** + * The date Orb starts billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + + /** + * 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 [activePlanPhaseOrder]. + * + * Unlike [activePlanPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder + + /** + * Returns the raw JSON value of [adjustmentIntervals]. + * + * Unlike [adjustmentIntervals], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingCycleAnchorConfiguration]. + * + * Unlike [billingCycleAnchorConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [defaultInvoiceMemo]. + * + * Unlike [defaultInvoiceMemo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + /** + * Returns the raw JSON value of [discountIntervals]. + * + * Unlike [discountIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [fixedFeeQuantitySchedule]. + * + * Unlike [fixedFeeQuantitySchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule + + /** + * Returns the raw JSON value of [invoicingThreshold]. + * + * Unlike [invoicingThreshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold + + /** + * Returns the raw JSON value of [maximumIntervals]. + * + * Unlike [maximumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimumIntervals]. + * + * Unlike [minimumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals + + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + + /** + * Returns the raw JSON value of [plan]. + * + * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** + * Returns the raw JSON value of [priceIntervals]. + * + * Unlike [priceIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals + + /** + * Returns the raw JSON value of [redeemedCoupon]. + * + * Unlike [redeemedCoupon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [trialInfo]. + * + * Unlike [trialInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo + + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Subscription]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: + JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: + JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + id = subscription.id + activePlanPhaseOrder = subscription.activePlanPhaseOrder + adjustmentIntervals = subscription.adjustmentIntervals.map { it.toMutableList() } + autoCollection = subscription.autoCollection + billingCycleAnchorConfiguration = subscription.billingCycleAnchorConfiguration + billingCycleDay = subscription.billingCycleDay + createdAt = subscription.createdAt + currentBillingPeriodEndDate = subscription.currentBillingPeriodEndDate + currentBillingPeriodStartDate = subscription.currentBillingPeriodStartDate + customer = subscription.customer + defaultInvoiceMemo = subscription.defaultInvoiceMemo + discountIntervals = subscription.discountIntervals.map { it.toMutableList() } + endDate = subscription.endDate + fixedFeeQuantitySchedule = + subscription.fixedFeeQuantitySchedule.map { it.toMutableList() } + invoicingThreshold = subscription.invoicingThreshold + maximumIntervals = subscription.maximumIntervals.map { it.toMutableList() } + metadata = subscription.metadata + minimumIntervals = subscription.minimumIntervals.map { it.toMutableList() } + netTerms = subscription.netTerms + pendingSubscriptionChange = subscription.pendingSubscriptionChange + plan = subscription.plan + priceIntervals = subscription.priceIntervals.map { it.toMutableList() } + redeemedCoupon = subscription.redeemedCoupon + startDate = subscription.startDate + status = subscription.status + trialInfo = subscription.trialInfo + changedResources = subscription.changedResources + additionalProperties = subscription.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 current plan phase that is active, only if the subscription's plan has phases. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + + /** + * Alias for [Builder.activePlanPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** + * Alias for calling [Builder.activePlanPhaseOrder] with + * `activePlanPhaseOrder.orElse(null)`. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.getOrNull()) + + /** + * Sets [Builder.activePlanPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.activePlanPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + /** + * The adjustment intervals for this subscription sorted by the start_date of the + * adjustment interval. + */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** + * Sets [Builder.adjustmentIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [AdjustmentInterval] to [adjustmentIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. This property defaults to the + * plan's behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + /** + * Sets [Builder.billingCycleAnchorConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAnchorConfiguration] with a well-typed + * [BillingCycleAnchorConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions + * that are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if the + * subscription is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * A customer is a buyer of your products, and the other party to the billing + * relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's + * often desirable to have these match existing identifiers in your system. To avoid + * having to denormalize Orb ID information, you can pass in an `external_customer_id` + * with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information + * about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the + * `payment_provider` enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for + * information on what this timezone parameter influences within Orb. + */ + fun customer(customer: Customer) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [Customer] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Alias for calling [Builder.defaultInvoiceMemo] with + * `defaultInvoiceMemo.orElse(null)`. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.getOrNull()) + + /** + * Sets [Builder.defaultInvoiceMemo] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultInvoiceMemo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** The discount intervals for this subscription sorted by the start_date. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** + * Sets [Builder.discountIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.discountIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountInterval] to [discountIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) + } + } + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ + fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + addDiscountInterval(DiscountInterval.ofAmount(amount)) + + /** + * Alias for calling [addDiscountInterval] with + * `DiscountInterval.ofPercentage(percentage)`. + */ + fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofPercentage(percentage)) + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ + fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofUsage(usage)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + /** + * Sets [Builder.fixedFeeQuantitySchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantitySchedule] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantitySchedule] to [Builder.fixedFeeQuantitySchedule]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + /** + * Alias for calling [Builder.invoicingThreshold] with + * `invoicingThreshold.orElse(null)`. + */ + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.getOrNull()) + + /** + * Sets [Builder.invoicingThreshold] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingThreshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The maximum intervals for this subscription sorted by the start_date. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** + * Sets [Builder.maximumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MaximumInterval] to [maximumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) + } + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The minimum intervals for this subscription sorted by the start_date. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** + * Sets [Builder.minimumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MinimumInterval] to [minimumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) + } + } + + /** + * Determines the difference between the invoice issue date for subscription invoices as + * the date that they are due. A value of `0` here represents that the invoice is due on + * issue, whereas a value of `30` represents that the customer has a month to pay the + * invoice. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. + * You can see more about how to configure prices in the + * [Price resource](/reference/price). + */ + fun plan(plan: Plan) = plan(JsonField.of(plan)) + + /** + * Sets [Builder.plan] to an arbitrary JSON value. + * + * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun plan(plan: JsonField) = apply { this.plan = plan } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** + * Sets [Builder.priceIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.priceIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [PriceInterval] to [priceIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + /** Alias for calling [Builder.redeemedCoupon] with `redeemedCoupon.orElse(null)`. */ + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.getOrNull()) + + /** + * Sets [Builder.redeemedCoupon] to an arbitrary JSON value. + * + * You should usually call [Builder.redeemedCoupon] with a well-typed [RedeemedCoupon] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + /** + * Sets [Builder.trialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.trialInfo] with a well-typed [TrialInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter + * was passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** + * Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. + */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed + * [ChangedResources] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + 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 + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("id", id), + checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), + checkRequired("adjustmentIntervals", adjustmentIntervals).map { + it.toImmutable() + }, + checkRequired("autoCollection", autoCollection), + checkRequired( + "billingCycleAnchorConfiguration", + billingCycleAnchorConfiguration, + ), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("createdAt", createdAt), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("customer", customer), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, + checkRequired("endDate", endDate), + checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { + it.toImmutable() + }, + checkRequired("invoicingThreshold", invoicingThreshold), + checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, + checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), + checkRequired("plan", plan), + checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, + checkRequired("redeemedCoupon", redeemedCoupon), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("trialInfo", trialInfo), + changedResources, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + id() + activePlanPhaseOrder() + adjustmentIntervals().forEach { it.validate() } + autoCollection() + billingCycleAnchorConfiguration().validate() + billingCycleDay() + createdAt() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + customer().validate() + defaultInvoiceMemo() + discountIntervals().forEach { it.validate() } + endDate() + fixedFeeQuantitySchedule().forEach { it.validate() } + invoicingThreshold() + maximumIntervals().forEach { it.validate() } + metadata().validate() + minimumIntervals().forEach { it.validate() } + netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } + plan().validate() + priceIntervals().forEach { it.validate() } + redeemedCoupon().ifPresent { it.validate() } + startDate() + status().validate() + trialInfo().validate() + changedResources().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) + + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The price interval IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * 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 [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AdjustmentInterval]. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdjustmentInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + id = adjustmentInterval.id + adjustment = adjustmentInterval.adjustment + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = adjustmentInterval.endDate + startDate = adjustmentInterval.startDate + additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + */ + fun adjustment( + planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + */ + fun adjustment( + planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + */ + fun adjustment( + planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment + ) = + adjustment( + Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) + ) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. + */ + fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. + */ + fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AdjustmentInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AdjustmentInterval = + AdjustmentInterval( + checkRequired("id", id), + checkRequired("adjustment", adjustment), + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdjustmentInterval = apply { + if (validated) { + return@apply + } + + id() + adjustment().validate() + appliesToPriceIntervalIds() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, + private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, + private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = + null, + private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, + private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + fun planPhaseUsageDiscount(): Optional = + Optional.ofNullable(planPhaseUsageDiscount) + + fun planPhaseAmountDiscount(): Optional = + Optional.ofNullable(planPhaseAmountDiscount) + + fun planPhasePercentageDiscount(): Optional = + Optional.ofNullable(planPhasePercentageDiscount) + + fun planPhaseMinimum(): Optional = + Optional.ofNullable(planPhaseMinimum) + + fun planPhaseMaximum(): Optional = + Optional.ofNullable(planPhaseMaximum) + + fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + + fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + + fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + + fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + + fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + + fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = + planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + + fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = + planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + + fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = + planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + + fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = + planPhaseMinimum.getOrThrow("planPhaseMinimum") + + fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = + planPhaseMaximum.getOrThrow("planPhaseMaximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + planPhaseUsageDiscount != null -> + visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) + planPhaseAmountDiscount != null -> + visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) + planPhasePercentageDiscount != null -> + visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) + planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) + planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) { + planPhaseUsageDiscount.validate() + } + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) { + planPhaseAmountDiscount.validate() + } + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) { + planPhasePercentageDiscount.validate() + } + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) { + planPhaseMinimum.validate() + } + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) { + planPhaseMaximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + + override fun toString(): String = + when { + planPhaseUsageDiscount != null -> + "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" + planPhaseAmountDiscount != null -> + "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" + planPhasePercentageDiscount != null -> + "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" + planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" + planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + + @JvmStatic + fun ofPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + + @JvmStatic + fun ofPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + + @JvmStatic + fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = + Adjustment(planPhaseMinimum = planPhaseMinimum) + + @JvmStatic + fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = + Adjustment(planPhaseMaximum = planPhaseMaximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of + * type [T]. + */ + interface Visitor { + + fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ): T + + fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ): T + + fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ): T + + fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + + fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json + .asObject() + .getOrNull() + ?.get("adjustment_type") + ?.asString() + ?.getOrNull() + + when (adjustmentType) { + "usage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "percentage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Adjustment(planPhasePercentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.planPhaseUsageDiscount != null -> + generator.writeObject(value.planPhaseUsageDiscount) + value.planPhaseAmountDiscount != null -> + generator.writeObject(value.planPhaseAmountDiscount) + value.planPhasePercentageDiscount != null -> + generator.writeObject(value.planPhasePercentageDiscount) + value.planPhaseMinimum != null -> + generator.writeObject(value.planPhaseMinimum) + value.planPhaseMaximum != null -> + generator.writeObject(value.planPhaseMaximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + class PlanPhaseUsageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + usageDiscount, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseUsageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ) = apply { + id = planPhaseUsageDiscountAdjustment.id + adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder + reason = planPhaseUsageDiscountAdjustment.reason + usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount + additionalProperties = + planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseUsageDiscountAdjustment = + PlanPhaseUsageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_DISCOUNT = of("usage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + USAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + class PlanPhaseAmountDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + amountDiscount, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The amount by which to discount the prices this adjustment applies to in a + * given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseAmountDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) = apply { + id = planPhaseAmountDiscountAdjustment.id + adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType + amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + appliesToPriceIds = + planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder + reason = planPhaseAmountDiscountAdjustment.reason + additionalProperties = + planPhaseAmountDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * The amount by which to discount the prices this adjustment applies to in + * a given billing period. + */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseAmountDiscountAdjustment = + PlanPhaseAmountDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT_DISCOUNT = of("amount_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + AMOUNT_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhasePercentageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val percentageDiscount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + percentageDiscount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The percentage (as a value between 0 and 1) by which to discount the price + * intervals this adjustment applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhasePercentageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhasePercentageDiscountAdjustment: + PlanPhasePercentageDiscountAdjustment + ) = apply { + id = planPhasePercentageDiscountAdjustment.id + adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel + percentageDiscount = + planPhasePercentageDiscountAdjustment.percentageDiscount + planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder + reason = planPhasePercentageDiscountAdjustment.reason + additionalProperties = + planPhasePercentageDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The percentage (as a value between 0 and 1) by which to discount the + * price intervals this adjustment applies to in a given billing period. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhasePercentageDiscountAdjustment = + PlanPhasePercentageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + percentageDiscount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + PERCENTAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMinimumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val itemId: JsonField, + private val minimumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + itemId, + minimumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The item ID that revenue from this minimum will be attributed to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("item_id") + @ExcludeMissing + fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMinimumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMinimumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = + apply { + id = planPhaseMinimumAdjustment.id + adjustmentType = planPhaseMinimumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMinimumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel + itemId = planPhaseMinimumAdjustment.itemId + minimumAmount = planPhaseMinimumAdjustment.minimumAmount + planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder + reason = planPhaseMinimumAdjustment.reason + additionalProperties = + planPhaseMinimumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The minimum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMinimumAdjustment = + PlanPhaseMinimumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("itemId", itemId), + checkRequired("minimumAmount", minimumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMinimumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + itemId() + minimumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MINIMUM = of("minimum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMaximumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val maximumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + maximumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMaximumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMaximumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = + apply { + id = planPhaseMaximumAdjustment.id + adjustmentType = planPhaseMaximumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMaximumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel + maximumAmount = planPhaseMaximumAdjustment.maximumAmount + planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder + reason = planPhaseMaximumAdjustment.reason + additionalProperties = + planPhaseMaximumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The maximum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMaximumAdjustment = + PlanPhaseMaximumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("maximumAmount", maximumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMaximumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + maximumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MAXIMUM = of("maximum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MAXIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAXIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day") @ExcludeMissing day: JsonField = JsonMissing.of(), + @JsonProperty("month") @ExcludeMissing month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing year: JsonField = JsonMissing.of(), + ) : this(day, month, year, mutableMapOf()) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun day(): Long = day.getRequired("day") + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun month(): Optional = month.getOptional("month") + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun year(): Optional = year.getOptional("year") + + /** + * Returns the raw JSON value of [day]. + * + * Unlike [day], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day + + /** + * Returns the raw JSON value of [month]. + * + * Unlike [month], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * Returns the raw JSON value of [year]. + * + * Unlike [year], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BillingCycleAnchorConfiguration]. + * + * The following fields are required: + * ```java + * .day() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleAnchorConfiguration]. */ + class Builder internal constructor() { + + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = apply { + day = billingCycleAnchorConfiguration.day + month = billingCycleAnchorConfiguration.month + year = billingCycleAnchorConfiguration.year + additionalProperties = + billingCycleAnchorConfiguration.additionalProperties.toMutableMap() + } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum + * number of days in a month is greater than this value, the last day of the month + * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing + * period begins on the 30th. + */ + fun day(day: Long) = day(JsonField.of(day)) + + /** + * Sets [Builder.day] to an arbitrary JSON value. + * + * You should usually call [Builder.day] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun day(day: JsonField) = apply { this.day = day } + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored + * in February would have cycles starting February, May, August, and November). + */ + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * Alias for [Builder.month]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun month(month: Long) = month(month as Long?) + + /** Alias for calling [Builder.month] with `month.orElse(null)`. */ + fun month(month: Optional) = month(month.getOrNull()) + + /** + * Sets [Builder.month] to an arbitrary JSON value. + * + * You should usually call [Builder.month] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun month(month: JsonField) = apply { this.month = month } + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle + * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * Alias for [Builder.year]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun year(year: Long) = year(year as Long?) + + /** Alias for calling [Builder.year] with `year.orElse(null)`. */ + fun year(year: Optional) = year(year.getOrNull()) + + /** + * Sets [Builder.year] to an arbitrary JSON value. + * + * You should usually call [Builder.year] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingCycleAnchorConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .day() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + checkRequired("day", day), + month, + year, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (validated) { + return@apply + } + + day() + month() + year() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval + private constructor( + private val amount: AmountDiscountInterval? = null, + private val percentage: PercentageDiscountInterval? = null, + private val usage: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + fun amount(): Optional = Optional.ofNullable(amount) + + fun percentage(): Optional = Optional.ofNullable(percentage) + + fun usage(): Optional = Optional.ofNullable(usage) + + fun isAmount(): Boolean = amount != null + + fun isPercentage(): Boolean = percentage != null + + fun isUsage(): Boolean = usage != null + + fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + + fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + + fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + amount != null -> visitor.visitAmount(amount) + percentage != null -> visitor.visitPercentage(percentage) + usage != null -> visitor.visitUsage(usage) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DiscountInterval = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) { + amount.validate() + } + + override fun visitPercentage(percentage: PercentageDiscountInterval) { + percentage.validate() + } + + override fun visitUsage(usage: UsageDiscountInterval) { + usage.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + + override fun toString(): String = + when { + amount != null -> "DiscountInterval{amount=$amount}" + percentage != null -> "DiscountInterval{percentage=$percentage}" + usage != null -> "DiscountInterval{usage=$usage}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + + companion object { + + @JvmStatic + fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + + @JvmStatic + fun ofPercentage(percentage: PercentageDiscountInterval) = + DiscountInterval(percentage = percentage) + + @JvmStatic + fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + } + + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAmount(amount: AmountDiscountInterval): T + + fun visitPercentage(percentage: PercentageDiscountInterval): T + + fun visitUsage(usage: UsageDiscountInterval): T + + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + internal class Deserializer : + BaseDeserializer(DiscountInterval::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(amount = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "percentage" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "usage" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(usage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amount != null -> generator.writeObject(value.amount) + value.percentage != null -> generator.writeObject(value.percentage) + value.usage != null -> generator.writeObject(value.usage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + class AmountDiscountInterval + private constructor( + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + amountDiscount, + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * Only available if discount_type is `amount`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AmountDiscountInterval]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AmountDiscountInterval]. */ + class Builder internal constructor() { + + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + amountDiscount = amountDiscountInterval.amountDiscount + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = amountDiscountInterval.discountType + endDate = amountDiscountInterval.endDate + startDate = amountDiscountInterval.startDate + additionalProperties = + amountDiscountInterval.additionalProperties.toMutableMap() + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AmountDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AmountDiscountInterval = apply { + if (validated) { + return@apply + } + + amountDiscount() + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + AMOUNT + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class PercentageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + percentageDiscount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Only available if discount_type is `percentage`.This is a number between 0 and 1. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = + apply { + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { + it.toMutableList() + } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = percentageDiscountInterval.discountType + endDate = percentageDiscountInterval.endDate + percentageDiscount = percentageDiscountInterval.percentageDiscount + startDate = percentageDiscountInterval.startDate + additionalProperties = + percentageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** + * Only available if discount_type is `percentage`.This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + percentageDiscount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class UsageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + usageDiscount, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UsageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = usageDiscountInterval.discountType + endDate = usageDiscountInterval.endDate + startDate = usageDiscountInterval.startDate + usageDiscount = usageDiscountInterval.usageDiscount + additionalProperties = + usageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE = of("usage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + USAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + } + + class FixedFeeQuantitySchedule + private constructor( + private val endDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(endDate, priceId, quantity, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FixedFeeQuantitySchedule]. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantitySchedule]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + endDate = fixedFeeQuantitySchedule.endDate + priceId = fixedFeeQuantitySchedule.priceId + quantity = fixedFeeQuantitySchedule.quantity + startDate = fixedFeeQuantitySchedule.startDate + additionalProperties = + fixedFeeQuantitySchedule.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + 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 startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedFeeQuantitySchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + checkRequired("endDate", endDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantitySchedule = apply { + if (validated) { + return@apply + } + + endDate() + priceId() + quantity() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class MaximumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val maximumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + maximumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The start date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MaximumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = maximumInterval.endDate + maximumAmount = maximumInterval.maximumAmount + startDate = maximumInterval.startDate + additionalProperties = maximumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The maximum amount to charge in a given billing period for the price intervals + * this transform applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaximumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumInterval = + MaximumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("maximumAmount", maximumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + maximumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class MinimumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val minimumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + minimumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The start date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = minimumInterval.endDate + minimumAmount = minimumInterval.minimumAmount + startDate = minimumInterval.startDate + additionalProperties = minimumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The minimum amount to charge in a given billing period for the price intervals + * this minimum applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumInterval = + MinimumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("minimumAmount", minimumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + minimumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = + pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * The Price Interval resource represents a period of time for which a price will bill on a + * subscription. A subscription’s price intervals define its billing behavior. + */ + class PriceInterval + private constructor( + private val id: JsonField, + private val billingCycleDay: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val endDate: JsonField, + private val filter: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val price: JsonField, + private val startDate: JsonField, + private val usageCustomerIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_customer_ids") + @ExcludeMissing + usageCustomerIds: JsonField> = JsonMissing.of(), + ) : this( + id, + billingCycleDay, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + endDate, + filter, + fixedFeeQuantityTransitions, + price, + startDate, + usageCustomerIds, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The day of the month that Orb bills for this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * An additional filter to apply to usage queries. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedFeeQuantityTransitions(): Optional> = + fixedFeeQuantityTransitions.getOptional("fixed_fee_quantity_transitions") + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun price(): Price = price.getRequired("price") + + /** + * The start date of the price interval. This is the date that Orb starts billing for + * this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this + * price interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usageCustomerIds(): Optional> = + usageCustomerIds.getOptional("usage_customer_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 + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = + currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [fixedFeeQuantityTransitions]. + * + * Unlike [fixedFeeQuantityTransitions], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageCustomerIds]. + * + * Unlike [usageCustomerIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_customer_ids") + @ExcludeMissing + fun _usageCustomerIds(): JsonField> = usageCustomerIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceInterval]. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var filter: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null + private var usageCustomerIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + id = priceInterval.id + billingCycleDay = priceInterval.billingCycleDay + currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + endDate = priceInterval.endDate + filter = priceInterval.filter + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } + price = priceInterval.price + startDate = priceInterval.startDate + usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + additionalProperties = priceInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 day of the month that Orb bills for this price */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that + * the instant returned is exactly the end of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: Optional + ) = currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate( + JsonField.ofNullable(currentBillingPeriodStartDate) + ) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * The end date of the price interval. This is the date that Orb stops billing for + * this price. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** An additional filter to apply to usage queries. */ + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant + * for fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * Alias for calling [Builder.fixedFeeQuantityTransitions] with + * `fixedFeeQuantityTransitions.orElse(null)`. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.getOrNull()) + + /** + * Sets [Builder.fixedFeeQuantityTransitions] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantityTransitions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantityTransition] to [fixedFeeQuantityTransitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) + .add(fixedFeeQuantityTransition) + } + } + + /** + * The Price resource represents a price that can be billed on a subscription, + * resulting in a charge on an invoice in the form of an invoice line item. Prices + * take a quantity and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models + * is serialized differently in a given Price object. The model_type field + * determines the key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: Price) = price(JsonField.of(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + + /** + * Alias for calling [price] with + * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** + * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. + */ + fun price(unitWithProration: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** + * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. + */ + fun price(groupedAllocation: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. + */ + fun price(bulkWithProration: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * The start date of the price interval. This is the date that Orb starts billing + * for this price. + */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * A list of customer IDs whose usage events will be aggregated and billed under + * this price interval. + */ + fun usageCustomerIds(usageCustomerIds: List?) = + usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) + + /** + * Alias for calling [Builder.usageCustomerIds] with + * `usageCustomerIds.orElse(null)`. + */ + fun usageCustomerIds(usageCustomerIds: Optional>) = + usageCustomerIds(usageCustomerIds.getOrNull()) + + /** + * Sets [Builder.usageCustomerIds] to an arbitrary JSON value. + * + * You should usually call [Builder.usageCustomerIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { + this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [usageCustomerIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUsageCustomerId(usageCustomerId: String) = apply { + usageCustomerIds = + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PriceInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceInterval = + PriceInterval( + checkRequired("id", id), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired( + "currentBillingPeriodStartDate", + currentBillingPeriodStartDate, + ), + checkRequired("endDate", endDate), + checkRequired("filter", filter), + checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions) + .map { it.toImmutable() }, + checkRequired("price", price), + checkRequired("startDate", startDate), + checkRequired("usageCustomerIds", usageCustomerIds).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PriceInterval = apply { + if (validated) { + return@apply + } + + id() + billingCycleDay() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + endDate() + filter() + fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + price().validate() + startDate() + usageCustomerIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + class FixedFeeQuantityTransition + private constructor( + private val effectiveDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(effectiveDate, priceId, quantity, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_id") + @ExcludeMissing + fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 + * [FixedFeeQuantityTransition]. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantityTransition]. */ + class Builder internal constructor() { + + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = + apply { + effectiveDate = fixedFeeQuantityTransition.effectiveDate + priceId = fixedFeeQuantityTransition.priceId + quantity = fixedFeeQuantityTransition.quantity + additionalProperties = + fixedFeeQuantityTransition.additionalProperties.toMutableMap() + } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Long] 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 [FixedFeeQuantityTransition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + checkRequired("effectiveDate", effectiveDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (validated) { + return@apply + } + + effectiveDate() + priceId() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } + + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("coupon_id") + @ExcludeMissing + couponId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(couponId, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun couponId(): String = couponId.getRequired("coupon_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [couponId]. + * + * Unlike [couponId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RedeemedCoupon]. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RedeemedCoupon]. */ + class Builder internal constructor() { + + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + couponId = redeemedCoupon.couponId + endDate = redeemedCoupon.endDate + startDate = redeemedCoupon.startDate + additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + /** + * Sets [Builder.couponId] to an arbitrary JSON value. + * + * You should usually call [Builder.couponId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RedeemedCoupon]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RedeemedCoupon = + RedeemedCoupon( + checkRequired("couponId", couponId), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RedeemedCoupon = apply { + if (validated) { + return@apply + } + + couponId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val ENDED = of("ended") + + @JvmField val UPCOMING = of("upcoming") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TrialInfo]. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrialInfo]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + endDate = trialInfo.endDate + additionalProperties = trialInfo.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TrialInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TrialInfo = + TrialInfo( + checkRequired("endDate", endDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TrialInfo = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = + changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = + changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { + it.toImmutable() + }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Subscription{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeApplyResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionChangeApplyResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt new file mode 100644 index 00000000..8e7d2940 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * Cancel a subscription change. The change can no longer be applied. A subscription can only have + * one "pending" change at a time - use this endpoint to cancel an existing change before creating a + * new one. + */ +class SubscriptionChangeCancelParams +private constructor( + private val subscriptionChangeId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun subscriptionChangeId(): String = subscriptionChangeId + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeCancelParams]. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeCancelParams]. */ + class Builder internal constructor() { + + private var subscriptionChangeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionChangeCancelParams: SubscriptionChangeCancelParams) = apply { + subscriptionChangeId = subscriptionChangeCancelParams.subscriptionChangeId + additionalHeaders = subscriptionChangeCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = subscriptionChangeCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + subscriptionChangeCancelParams.additionalBodyProperties.toMutableMap() + } + + fun subscriptionChangeId(subscriptionChangeId: String) = apply { + this.subscriptionChangeId = subscriptionChangeId + } + + 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) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SubscriptionChangeCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeCancelParams = + SubscriptionChangeCancelParams( + checkRequired("subscriptionChangeId", subscriptionChangeId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> subscriptionChangeId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeCancelParams && subscriptionChangeId == other.subscriptionChangeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "SubscriptionChangeCancelParams{subscriptionChangeId=$subscriptionChangeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt new file mode 100644 index 00000000..8706a849 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt @@ -0,0 +1,11498 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A subscription change represents a desired new subscription / pending change to an existing + * subscription. It is a way to first preview the effects on the subscription as well as any + * changes/creation of invoices (see `subscription.changed_resources`). + */ +class SubscriptionChangeCancelResponse +private constructor( + private val id: JsonField, + private val expirationTime: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val appliedAt: JsonField, + private val cancelledAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("expiration_time") + @ExcludeMissing + expirationTime: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("applied_at") + @ExcludeMissing + appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("cancelled_at") + @ExcludeMissing + cancelledAt: JsonField = JsonMissing.of(), + ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Subscription change will be cancelled at this time and can no longer be applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun expirationTime(): OffsetDateTime = expirationTime.getRequired("expiration_time") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): Optional = subscription.getOptional("subscription") + + /** + * When this change was applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun appliedAt(): Optional = appliedAt.getOptional("applied_at") + + /** + * When this change was cancelled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun cancelledAt(): Optional = cancelledAt.getOptional("cancelled_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 [expirationTime]. + * + * Unlike [expirationTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiration_time") + @ExcludeMissing + fun _expirationTime(): JsonField = expirationTime + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [appliedAt]. + * + * Unlike [appliedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("applied_at") + @ExcludeMissing + fun _appliedAt(): JsonField = appliedAt + + /** + * Returns the raw JSON value of [cancelledAt]. + * + * Unlike [cancelledAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cancelled_at") + @ExcludeMissing + fun _cancelledAt(): JsonField = cancelledAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeCancelResponse]. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeCancelResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var expirationTime: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var appliedAt: JsonField = JsonMissing.of() + private var cancelledAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionChangeCancelResponse: SubscriptionChangeCancelResponse) = + apply { + id = subscriptionChangeCancelResponse.id + expirationTime = subscriptionChangeCancelResponse.expirationTime + status = subscriptionChangeCancelResponse.status + subscription = subscriptionChangeCancelResponse.subscription + appliedAt = subscriptionChangeCancelResponse.appliedAt + cancelledAt = subscriptionChangeCancelResponse.cancelledAt + additionalProperties = + subscriptionChangeCancelResponse.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 } + + /** Subscription change will be cancelled at this time and can no longer be applied. */ + fun expirationTime(expirationTime: OffsetDateTime) = + expirationTime(JsonField.of(expirationTime)) + + /** + * Sets [Builder.expirationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.expirationTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expirationTime(expirationTime: JsonField) = apply { + this.expirationTime = expirationTime + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [Subscription] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** When this change was applied. */ + fun appliedAt(appliedAt: OffsetDateTime?) = appliedAt(JsonField.ofNullable(appliedAt)) + + /** Alias for calling [Builder.appliedAt] with `appliedAt.orElse(null)`. */ + fun appliedAt(appliedAt: Optional) = appliedAt(appliedAt.getOrNull()) + + /** + * Sets [Builder.appliedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.appliedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + + /** When this change was cancelled. */ + fun cancelledAt(cancelledAt: OffsetDateTime?) = + cancelledAt(JsonField.ofNullable(cancelledAt)) + + /** Alias for calling [Builder.cancelledAt] with `cancelledAt.orElse(null)`. */ + fun cancelledAt(cancelledAt: Optional) = + cancelledAt(cancelledAt.getOrNull()) + + /** + * Sets [Builder.cancelledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.cancelledAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancelledAt(cancelledAt: JsonField) = apply { + this.cancelledAt = cancelledAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionChangeCancelResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeCancelResponse = + SubscriptionChangeCancelResponse( + checkRequired("id", id), + checkRequired("expirationTime", expirationTime), + checkRequired("status", status), + checkRequired("subscription", subscription), + appliedAt, + cancelledAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubscriptionChangeCancelResponse = apply { + if (validated) { + return@apply + } + + id() + expirationTime() + status().validate() + subscription().ifPresent { it.validate() } + appliedAt() + cancelledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (expirationTime.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (appliedAt.asKnown().isPresent) 1 else 0) + + (if (cancelledAt.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val APPLIED = of("applied") + + @JvmField val CANCELLED = of("cancelled") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + APPLIED, + CANCELLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + APPLIED, + CANCELLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + APPLIED -> Value.APPLIED + CANCELLED -> Value.CANCELLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + APPLIED -> Known.APPLIED + CANCELLED -> Known.CANCELLED + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Subscription + private constructor( + private val id: JsonField, + private val activePlanPhaseOrder: JsonField, + private val adjustmentIntervals: JsonField>, + private val autoCollection: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val billingCycleDay: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val customer: JsonField, + private val defaultInvoiceMemo: JsonField, + private val discountIntervals: JsonField>, + private val endDate: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val invoicingThreshold: JsonField, + private val maximumIntervals: JsonField>, + private val metadata: JsonField, + private val minimumIntervals: JsonField>, + private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, + private val plan: JsonField, + private val priceIntervals: JsonField>, + private val redeemedCoupon: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val changedResources: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + activePlanPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_intervals") + @ExcludeMissing + adjustmentIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("discount_intervals") + @ExcludeMissing + discountIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fixedFeeQuantitySchedule: JsonField> = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("maximum_intervals") + @ExcludeMissing + maximumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum_intervals") + @ExcludeMissing + minimumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), + @JsonProperty("price_intervals") + @ExcludeMissing + priceIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("redeemed_coupon") + @ExcludeMissing + redeemedCoupon: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("trial_info") + @ExcludeMissing + trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), + ) : this( + id, + activePlanPhaseOrder, + adjustmentIntervals, + autoCollection, + billingCycleAnchorConfiguration, + billingCycleDay, + createdAt, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + customer, + defaultInvoiceMemo, + discountIntervals, + endDate, + fixedFeeQuantitySchedule, + invoicingThreshold, + maximumIntervals, + metadata, + minimumIntervals, + netTerms, + pendingSubscriptionChange, + plan, + priceIntervals, + redeemedCoupon, + startDate, + status, + trialInfo, + changedResources, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The current plan phase that is active, only if the subscription's plan has phases. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun activePlanPhaseOrder(): Optional = + activePlanPhaseOrder.getOptional("active_plan_phase_order") + + /** + * The adjustment intervals for this subscription sorted by the start_date of the adjustment + * interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultInvoiceMemo(): Optional = + defaultInvoiceMemo.getOptional("default_invoice_memo") + + /** + * The discount intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** + * The date Orb stops billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingThreshold(): Optional = + invoicingThreshold.getOptional("invoicing_threshold") + + /** + * The maximum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maximumIntervals(): List = + maximumIntervals.getRequired("maximum_intervals") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * The minimum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun plan(): Plan = plan.getRequired("plan") + + /** + * The price intervals for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun redeemedCoupon(): Optional = + redeemedCoupon.getOptional("redeemed_coupon") + + /** + * The date Orb starts billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + + /** + * 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 [activePlanPhaseOrder]. + * + * Unlike [activePlanPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder + + /** + * Returns the raw JSON value of [adjustmentIntervals]. + * + * Unlike [adjustmentIntervals], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingCycleAnchorConfiguration]. + * + * Unlike [billingCycleAnchorConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [defaultInvoiceMemo]. + * + * Unlike [defaultInvoiceMemo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + /** + * Returns the raw JSON value of [discountIntervals]. + * + * Unlike [discountIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [fixedFeeQuantitySchedule]. + * + * Unlike [fixedFeeQuantitySchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule + + /** + * Returns the raw JSON value of [invoicingThreshold]. + * + * Unlike [invoicingThreshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold + + /** + * Returns the raw JSON value of [maximumIntervals]. + * + * Unlike [maximumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimumIntervals]. + * + * Unlike [minimumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals + + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + + /** + * Returns the raw JSON value of [plan]. + * + * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** + * Returns the raw JSON value of [priceIntervals]. + * + * Unlike [priceIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals + + /** + * Returns the raw JSON value of [redeemedCoupon]. + * + * Unlike [redeemedCoupon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [trialInfo]. + * + * Unlike [trialInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo + + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Subscription]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: + JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: + JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + id = subscription.id + activePlanPhaseOrder = subscription.activePlanPhaseOrder + adjustmentIntervals = subscription.adjustmentIntervals.map { it.toMutableList() } + autoCollection = subscription.autoCollection + billingCycleAnchorConfiguration = subscription.billingCycleAnchorConfiguration + billingCycleDay = subscription.billingCycleDay + createdAt = subscription.createdAt + currentBillingPeriodEndDate = subscription.currentBillingPeriodEndDate + currentBillingPeriodStartDate = subscription.currentBillingPeriodStartDate + customer = subscription.customer + defaultInvoiceMemo = subscription.defaultInvoiceMemo + discountIntervals = subscription.discountIntervals.map { it.toMutableList() } + endDate = subscription.endDate + fixedFeeQuantitySchedule = + subscription.fixedFeeQuantitySchedule.map { it.toMutableList() } + invoicingThreshold = subscription.invoicingThreshold + maximumIntervals = subscription.maximumIntervals.map { it.toMutableList() } + metadata = subscription.metadata + minimumIntervals = subscription.minimumIntervals.map { it.toMutableList() } + netTerms = subscription.netTerms + pendingSubscriptionChange = subscription.pendingSubscriptionChange + plan = subscription.plan + priceIntervals = subscription.priceIntervals.map { it.toMutableList() } + redeemedCoupon = subscription.redeemedCoupon + startDate = subscription.startDate + status = subscription.status + trialInfo = subscription.trialInfo + changedResources = subscription.changedResources + additionalProperties = subscription.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 current plan phase that is active, only if the subscription's plan has phases. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + + /** + * Alias for [Builder.activePlanPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** + * Alias for calling [Builder.activePlanPhaseOrder] with + * `activePlanPhaseOrder.orElse(null)`. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.getOrNull()) + + /** + * Sets [Builder.activePlanPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.activePlanPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + /** + * The adjustment intervals for this subscription sorted by the start_date of the + * adjustment interval. + */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** + * Sets [Builder.adjustmentIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [AdjustmentInterval] to [adjustmentIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. This property defaults to the + * plan's behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + /** + * Sets [Builder.billingCycleAnchorConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAnchorConfiguration] with a well-typed + * [BillingCycleAnchorConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions + * that are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if the + * subscription is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * A customer is a buyer of your products, and the other party to the billing + * relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's + * often desirable to have these match existing identifiers in your system. To avoid + * having to denormalize Orb ID information, you can pass in an `external_customer_id` + * with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information + * about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the + * `payment_provider` enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for + * information on what this timezone parameter influences within Orb. + */ + fun customer(customer: Customer) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [Customer] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Alias for calling [Builder.defaultInvoiceMemo] with + * `defaultInvoiceMemo.orElse(null)`. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.getOrNull()) + + /** + * Sets [Builder.defaultInvoiceMemo] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultInvoiceMemo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** The discount intervals for this subscription sorted by the start_date. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** + * Sets [Builder.discountIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.discountIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountInterval] to [discountIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) + } + } + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ + fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + addDiscountInterval(DiscountInterval.ofAmount(amount)) + + /** + * Alias for calling [addDiscountInterval] with + * `DiscountInterval.ofPercentage(percentage)`. + */ + fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofPercentage(percentage)) + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ + fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofUsage(usage)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + /** + * Sets [Builder.fixedFeeQuantitySchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantitySchedule] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantitySchedule] to [Builder.fixedFeeQuantitySchedule]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + /** + * Alias for calling [Builder.invoicingThreshold] with + * `invoicingThreshold.orElse(null)`. + */ + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.getOrNull()) + + /** + * Sets [Builder.invoicingThreshold] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingThreshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The maximum intervals for this subscription sorted by the start_date. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** + * Sets [Builder.maximumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MaximumInterval] to [maximumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) + } + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The minimum intervals for this subscription sorted by the start_date. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** + * Sets [Builder.minimumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MinimumInterval] to [minimumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) + } + } + + /** + * Determines the difference between the invoice issue date for subscription invoices as + * the date that they are due. A value of `0` here represents that the invoice is due on + * issue, whereas a value of `30` represents that the customer has a month to pay the + * invoice. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. + * You can see more about how to configure prices in the + * [Price resource](/reference/price). + */ + fun plan(plan: Plan) = plan(JsonField.of(plan)) + + /** + * Sets [Builder.plan] to an arbitrary JSON value. + * + * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun plan(plan: JsonField) = apply { this.plan = plan } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** + * Sets [Builder.priceIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.priceIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [PriceInterval] to [priceIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + /** Alias for calling [Builder.redeemedCoupon] with `redeemedCoupon.orElse(null)`. */ + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.getOrNull()) + + /** + * Sets [Builder.redeemedCoupon] to an arbitrary JSON value. + * + * You should usually call [Builder.redeemedCoupon] with a well-typed [RedeemedCoupon] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + /** + * Sets [Builder.trialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.trialInfo] with a well-typed [TrialInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter + * was passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** + * Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. + */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed + * [ChangedResources] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + 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 + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("id", id), + checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), + checkRequired("adjustmentIntervals", adjustmentIntervals).map { + it.toImmutable() + }, + checkRequired("autoCollection", autoCollection), + checkRequired( + "billingCycleAnchorConfiguration", + billingCycleAnchorConfiguration, + ), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("createdAt", createdAt), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("customer", customer), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, + checkRequired("endDate", endDate), + checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { + it.toImmutable() + }, + checkRequired("invoicingThreshold", invoicingThreshold), + checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, + checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), + checkRequired("plan", plan), + checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, + checkRequired("redeemedCoupon", redeemedCoupon), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("trialInfo", trialInfo), + changedResources, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + id() + activePlanPhaseOrder() + adjustmentIntervals().forEach { it.validate() } + autoCollection() + billingCycleAnchorConfiguration().validate() + billingCycleDay() + createdAt() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + customer().validate() + defaultInvoiceMemo() + discountIntervals().forEach { it.validate() } + endDate() + fixedFeeQuantitySchedule().forEach { it.validate() } + invoicingThreshold() + maximumIntervals().forEach { it.validate() } + metadata().validate() + minimumIntervals().forEach { it.validate() } + netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } + plan().validate() + priceIntervals().forEach { it.validate() } + redeemedCoupon().ifPresent { it.validate() } + startDate() + status().validate() + trialInfo().validate() + changedResources().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) + + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The price interval IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * 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 [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AdjustmentInterval]. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdjustmentInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + id = adjustmentInterval.id + adjustment = adjustmentInterval.adjustment + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = adjustmentInterval.endDate + startDate = adjustmentInterval.startDate + additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + */ + fun adjustment( + planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + */ + fun adjustment( + planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + */ + fun adjustment( + planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment + ) = + adjustment( + Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) + ) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. + */ + fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. + */ + fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AdjustmentInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AdjustmentInterval = + AdjustmentInterval( + checkRequired("id", id), + checkRequired("adjustment", adjustment), + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdjustmentInterval = apply { + if (validated) { + return@apply + } + + id() + adjustment().validate() + appliesToPriceIntervalIds() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, + private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, + private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = + null, + private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, + private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + fun planPhaseUsageDiscount(): Optional = + Optional.ofNullable(planPhaseUsageDiscount) + + fun planPhaseAmountDiscount(): Optional = + Optional.ofNullable(planPhaseAmountDiscount) + + fun planPhasePercentageDiscount(): Optional = + Optional.ofNullable(planPhasePercentageDiscount) + + fun planPhaseMinimum(): Optional = + Optional.ofNullable(planPhaseMinimum) + + fun planPhaseMaximum(): Optional = + Optional.ofNullable(planPhaseMaximum) + + fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + + fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + + fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + + fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + + fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + + fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = + planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + + fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = + planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + + fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = + planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + + fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = + planPhaseMinimum.getOrThrow("planPhaseMinimum") + + fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = + planPhaseMaximum.getOrThrow("planPhaseMaximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + planPhaseUsageDiscount != null -> + visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) + planPhaseAmountDiscount != null -> + visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) + planPhasePercentageDiscount != null -> + visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) + planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) + planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) { + planPhaseUsageDiscount.validate() + } + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) { + planPhaseAmountDiscount.validate() + } + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) { + planPhasePercentageDiscount.validate() + } + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) { + planPhaseMinimum.validate() + } + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) { + planPhaseMaximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + + override fun toString(): String = + when { + planPhaseUsageDiscount != null -> + "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" + planPhaseAmountDiscount != null -> + "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" + planPhasePercentageDiscount != null -> + "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" + planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" + planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + + @JvmStatic + fun ofPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + + @JvmStatic + fun ofPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + + @JvmStatic + fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = + Adjustment(planPhaseMinimum = planPhaseMinimum) + + @JvmStatic + fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = + Adjustment(planPhaseMaximum = planPhaseMaximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of + * type [T]. + */ + interface Visitor { + + fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ): T + + fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ): T + + fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ): T + + fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + + fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json + .asObject() + .getOrNull() + ?.get("adjustment_type") + ?.asString() + ?.getOrNull() + + when (adjustmentType) { + "usage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "percentage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Adjustment(planPhasePercentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.planPhaseUsageDiscount != null -> + generator.writeObject(value.planPhaseUsageDiscount) + value.planPhaseAmountDiscount != null -> + generator.writeObject(value.planPhaseAmountDiscount) + value.planPhasePercentageDiscount != null -> + generator.writeObject(value.planPhasePercentageDiscount) + value.planPhaseMinimum != null -> + generator.writeObject(value.planPhaseMinimum) + value.planPhaseMaximum != null -> + generator.writeObject(value.planPhaseMaximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + class PlanPhaseUsageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + usageDiscount, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseUsageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ) = apply { + id = planPhaseUsageDiscountAdjustment.id + adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder + reason = planPhaseUsageDiscountAdjustment.reason + usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount + additionalProperties = + planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseUsageDiscountAdjustment = + PlanPhaseUsageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_DISCOUNT = of("usage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + USAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + class PlanPhaseAmountDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + amountDiscount, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The amount by which to discount the prices this adjustment applies to in a + * given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseAmountDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) = apply { + id = planPhaseAmountDiscountAdjustment.id + adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType + amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + appliesToPriceIds = + planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder + reason = planPhaseAmountDiscountAdjustment.reason + additionalProperties = + planPhaseAmountDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * The amount by which to discount the prices this adjustment applies to in + * a given billing period. + */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseAmountDiscountAdjustment = + PlanPhaseAmountDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT_DISCOUNT = of("amount_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + AMOUNT_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhasePercentageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val percentageDiscount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + percentageDiscount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The percentage (as a value between 0 and 1) by which to discount the price + * intervals this adjustment applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhasePercentageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhasePercentageDiscountAdjustment: + PlanPhasePercentageDiscountAdjustment + ) = apply { + id = planPhasePercentageDiscountAdjustment.id + adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel + percentageDiscount = + planPhasePercentageDiscountAdjustment.percentageDiscount + planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder + reason = planPhasePercentageDiscountAdjustment.reason + additionalProperties = + planPhasePercentageDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The percentage (as a value between 0 and 1) by which to discount the + * price intervals this adjustment applies to in a given billing period. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhasePercentageDiscountAdjustment = + PlanPhasePercentageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + percentageDiscount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + PERCENTAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMinimumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val itemId: JsonField, + private val minimumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + itemId, + minimumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The item ID that revenue from this minimum will be attributed to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("item_id") + @ExcludeMissing + fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMinimumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMinimumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = + apply { + id = planPhaseMinimumAdjustment.id + adjustmentType = planPhaseMinimumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMinimumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel + itemId = planPhaseMinimumAdjustment.itemId + minimumAmount = planPhaseMinimumAdjustment.minimumAmount + planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder + reason = planPhaseMinimumAdjustment.reason + additionalProperties = + planPhaseMinimumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The minimum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMinimumAdjustment = + PlanPhaseMinimumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("itemId", itemId), + checkRequired("minimumAmount", minimumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMinimumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + itemId() + minimumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MINIMUM = of("minimum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMaximumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val maximumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + maximumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMaximumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMaximumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = + apply { + id = planPhaseMaximumAdjustment.id + adjustmentType = planPhaseMaximumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMaximumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel + maximumAmount = planPhaseMaximumAdjustment.maximumAmount + planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder + reason = planPhaseMaximumAdjustment.reason + additionalProperties = + planPhaseMaximumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The maximum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMaximumAdjustment = + PlanPhaseMaximumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("maximumAmount", maximumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMaximumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + maximumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MAXIMUM = of("maximum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MAXIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAXIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day") @ExcludeMissing day: JsonField = JsonMissing.of(), + @JsonProperty("month") @ExcludeMissing month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing year: JsonField = JsonMissing.of(), + ) : this(day, month, year, mutableMapOf()) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun day(): Long = day.getRequired("day") + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun month(): Optional = month.getOptional("month") + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun year(): Optional = year.getOptional("year") + + /** + * Returns the raw JSON value of [day]. + * + * Unlike [day], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day + + /** + * Returns the raw JSON value of [month]. + * + * Unlike [month], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * Returns the raw JSON value of [year]. + * + * Unlike [year], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BillingCycleAnchorConfiguration]. + * + * The following fields are required: + * ```java + * .day() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleAnchorConfiguration]. */ + class Builder internal constructor() { + + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = apply { + day = billingCycleAnchorConfiguration.day + month = billingCycleAnchorConfiguration.month + year = billingCycleAnchorConfiguration.year + additionalProperties = + billingCycleAnchorConfiguration.additionalProperties.toMutableMap() + } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum + * number of days in a month is greater than this value, the last day of the month + * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing + * period begins on the 30th. + */ + fun day(day: Long) = day(JsonField.of(day)) + + /** + * Sets [Builder.day] to an arbitrary JSON value. + * + * You should usually call [Builder.day] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun day(day: JsonField) = apply { this.day = day } + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored + * in February would have cycles starting February, May, August, and November). + */ + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * Alias for [Builder.month]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun month(month: Long) = month(month as Long?) + + /** Alias for calling [Builder.month] with `month.orElse(null)`. */ + fun month(month: Optional) = month(month.getOrNull()) + + /** + * Sets [Builder.month] to an arbitrary JSON value. + * + * You should usually call [Builder.month] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun month(month: JsonField) = apply { this.month = month } + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle + * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * Alias for [Builder.year]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun year(year: Long) = year(year as Long?) + + /** Alias for calling [Builder.year] with `year.orElse(null)`. */ + fun year(year: Optional) = year(year.getOrNull()) + + /** + * Sets [Builder.year] to an arbitrary JSON value. + * + * You should usually call [Builder.year] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingCycleAnchorConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .day() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + checkRequired("day", day), + month, + year, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (validated) { + return@apply + } + + day() + month() + year() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval + private constructor( + private val amount: AmountDiscountInterval? = null, + private val percentage: PercentageDiscountInterval? = null, + private val usage: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + fun amount(): Optional = Optional.ofNullable(amount) + + fun percentage(): Optional = Optional.ofNullable(percentage) + + fun usage(): Optional = Optional.ofNullable(usage) + + fun isAmount(): Boolean = amount != null + + fun isPercentage(): Boolean = percentage != null + + fun isUsage(): Boolean = usage != null + + fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + + fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + + fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + amount != null -> visitor.visitAmount(amount) + percentage != null -> visitor.visitPercentage(percentage) + usage != null -> visitor.visitUsage(usage) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DiscountInterval = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) { + amount.validate() + } + + override fun visitPercentage(percentage: PercentageDiscountInterval) { + percentage.validate() + } + + override fun visitUsage(usage: UsageDiscountInterval) { + usage.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + + override fun toString(): String = + when { + amount != null -> "DiscountInterval{amount=$amount}" + percentage != null -> "DiscountInterval{percentage=$percentage}" + usage != null -> "DiscountInterval{usage=$usage}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + + companion object { + + @JvmStatic + fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + + @JvmStatic + fun ofPercentage(percentage: PercentageDiscountInterval) = + DiscountInterval(percentage = percentage) + + @JvmStatic + fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + } + + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAmount(amount: AmountDiscountInterval): T + + fun visitPercentage(percentage: PercentageDiscountInterval): T + + fun visitUsage(usage: UsageDiscountInterval): T + + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + internal class Deserializer : + BaseDeserializer(DiscountInterval::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(amount = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "percentage" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "usage" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(usage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amount != null -> generator.writeObject(value.amount) + value.percentage != null -> generator.writeObject(value.percentage) + value.usage != null -> generator.writeObject(value.usage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + class AmountDiscountInterval + private constructor( + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + amountDiscount, + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * Only available if discount_type is `amount`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AmountDiscountInterval]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AmountDiscountInterval]. */ + class Builder internal constructor() { + + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + amountDiscount = amountDiscountInterval.amountDiscount + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = amountDiscountInterval.discountType + endDate = amountDiscountInterval.endDate + startDate = amountDiscountInterval.startDate + additionalProperties = + amountDiscountInterval.additionalProperties.toMutableMap() + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AmountDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AmountDiscountInterval = apply { + if (validated) { + return@apply + } + + amountDiscount() + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + AMOUNT + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class PercentageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + percentageDiscount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Only available if discount_type is `percentage`.This is a number between 0 and 1. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = + apply { + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { + it.toMutableList() + } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = percentageDiscountInterval.discountType + endDate = percentageDiscountInterval.endDate + percentageDiscount = percentageDiscountInterval.percentageDiscount + startDate = percentageDiscountInterval.startDate + additionalProperties = + percentageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** + * Only available if discount_type is `percentage`.This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + percentageDiscount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class UsageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + usageDiscount, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UsageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = usageDiscountInterval.discountType + endDate = usageDiscountInterval.endDate + startDate = usageDiscountInterval.startDate + usageDiscount = usageDiscountInterval.usageDiscount + additionalProperties = + usageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE = of("usage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + USAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + } + + class FixedFeeQuantitySchedule + private constructor( + private val endDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(endDate, priceId, quantity, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FixedFeeQuantitySchedule]. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantitySchedule]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + endDate = fixedFeeQuantitySchedule.endDate + priceId = fixedFeeQuantitySchedule.priceId + quantity = fixedFeeQuantitySchedule.quantity + startDate = fixedFeeQuantitySchedule.startDate + additionalProperties = + fixedFeeQuantitySchedule.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + 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 startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedFeeQuantitySchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + checkRequired("endDate", endDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantitySchedule = apply { + if (validated) { + return@apply + } + + endDate() + priceId() + quantity() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class MaximumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val maximumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + maximumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The start date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MaximumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = maximumInterval.endDate + maximumAmount = maximumInterval.maximumAmount + startDate = maximumInterval.startDate + additionalProperties = maximumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The maximum amount to charge in a given billing period for the price intervals + * this transform applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaximumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumInterval = + MaximumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("maximumAmount", maximumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + maximumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class MinimumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val minimumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + minimumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The start date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = minimumInterval.endDate + minimumAmount = minimumInterval.minimumAmount + startDate = minimumInterval.startDate + additionalProperties = minimumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The minimum amount to charge in a given billing period for the price intervals + * this minimum applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumInterval = + MinimumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("minimumAmount", minimumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + minimumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = + pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * The Price Interval resource represents a period of time for which a price will bill on a + * subscription. A subscription’s price intervals define its billing behavior. + */ + class PriceInterval + private constructor( + private val id: JsonField, + private val billingCycleDay: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val endDate: JsonField, + private val filter: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val price: JsonField, + private val startDate: JsonField, + private val usageCustomerIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_customer_ids") + @ExcludeMissing + usageCustomerIds: JsonField> = JsonMissing.of(), + ) : this( + id, + billingCycleDay, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + endDate, + filter, + fixedFeeQuantityTransitions, + price, + startDate, + usageCustomerIds, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The day of the month that Orb bills for this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * An additional filter to apply to usage queries. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedFeeQuantityTransitions(): Optional> = + fixedFeeQuantityTransitions.getOptional("fixed_fee_quantity_transitions") + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun price(): Price = price.getRequired("price") + + /** + * The start date of the price interval. This is the date that Orb starts billing for + * this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this + * price interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usageCustomerIds(): Optional> = + usageCustomerIds.getOptional("usage_customer_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 + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = + currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [fixedFeeQuantityTransitions]. + * + * Unlike [fixedFeeQuantityTransitions], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageCustomerIds]. + * + * Unlike [usageCustomerIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_customer_ids") + @ExcludeMissing + fun _usageCustomerIds(): JsonField> = usageCustomerIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceInterval]. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var filter: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null + private var usageCustomerIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + id = priceInterval.id + billingCycleDay = priceInterval.billingCycleDay + currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + endDate = priceInterval.endDate + filter = priceInterval.filter + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } + price = priceInterval.price + startDate = priceInterval.startDate + usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + additionalProperties = priceInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 day of the month that Orb bills for this price */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that + * the instant returned is exactly the end of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: Optional + ) = currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate( + JsonField.ofNullable(currentBillingPeriodStartDate) + ) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * The end date of the price interval. This is the date that Orb stops billing for + * this price. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** An additional filter to apply to usage queries. */ + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant + * for fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * Alias for calling [Builder.fixedFeeQuantityTransitions] with + * `fixedFeeQuantityTransitions.orElse(null)`. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.getOrNull()) + + /** + * Sets [Builder.fixedFeeQuantityTransitions] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantityTransitions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantityTransition] to [fixedFeeQuantityTransitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) + .add(fixedFeeQuantityTransition) + } + } + + /** + * The Price resource represents a price that can be billed on a subscription, + * resulting in a charge on an invoice in the form of an invoice line item. Prices + * take a quantity and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models + * is serialized differently in a given Price object. The model_type field + * determines the key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: Price) = price(JsonField.of(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + + /** + * Alias for calling [price] with + * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** + * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. + */ + fun price(unitWithProration: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** + * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. + */ + fun price(groupedAllocation: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. + */ + fun price(bulkWithProration: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * The start date of the price interval. This is the date that Orb starts billing + * for this price. + */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * A list of customer IDs whose usage events will be aggregated and billed under + * this price interval. + */ + fun usageCustomerIds(usageCustomerIds: List?) = + usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) + + /** + * Alias for calling [Builder.usageCustomerIds] with + * `usageCustomerIds.orElse(null)`. + */ + fun usageCustomerIds(usageCustomerIds: Optional>) = + usageCustomerIds(usageCustomerIds.getOrNull()) + + /** + * Sets [Builder.usageCustomerIds] to an arbitrary JSON value. + * + * You should usually call [Builder.usageCustomerIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { + this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [usageCustomerIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUsageCustomerId(usageCustomerId: String) = apply { + usageCustomerIds = + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PriceInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceInterval = + PriceInterval( + checkRequired("id", id), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired( + "currentBillingPeriodStartDate", + currentBillingPeriodStartDate, + ), + checkRequired("endDate", endDate), + checkRequired("filter", filter), + checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions) + .map { it.toImmutable() }, + checkRequired("price", price), + checkRequired("startDate", startDate), + checkRequired("usageCustomerIds", usageCustomerIds).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PriceInterval = apply { + if (validated) { + return@apply + } + + id() + billingCycleDay() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + endDate() + filter() + fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + price().validate() + startDate() + usageCustomerIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + class FixedFeeQuantityTransition + private constructor( + private val effectiveDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(effectiveDate, priceId, quantity, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_id") + @ExcludeMissing + fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 + * [FixedFeeQuantityTransition]. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantityTransition]. */ + class Builder internal constructor() { + + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = + apply { + effectiveDate = fixedFeeQuantityTransition.effectiveDate + priceId = fixedFeeQuantityTransition.priceId + quantity = fixedFeeQuantityTransition.quantity + additionalProperties = + fixedFeeQuantityTransition.additionalProperties.toMutableMap() + } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Long] 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 [FixedFeeQuantityTransition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + checkRequired("effectiveDate", effectiveDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (validated) { + return@apply + } + + effectiveDate() + priceId() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } + + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("coupon_id") + @ExcludeMissing + couponId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(couponId, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun couponId(): String = couponId.getRequired("coupon_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [couponId]. + * + * Unlike [couponId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RedeemedCoupon]. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RedeemedCoupon]. */ + class Builder internal constructor() { + + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + couponId = redeemedCoupon.couponId + endDate = redeemedCoupon.endDate + startDate = redeemedCoupon.startDate + additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + /** + * Sets [Builder.couponId] to an arbitrary JSON value. + * + * You should usually call [Builder.couponId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RedeemedCoupon]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RedeemedCoupon = + RedeemedCoupon( + checkRequired("couponId", couponId), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RedeemedCoupon = apply { + if (validated) { + return@apply + } + + couponId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val ENDED = of("ended") + + @JvmField val UPCOMING = of("upcoming") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TrialInfo]. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrialInfo]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + endDate = trialInfo.endDate + additionalProperties = trialInfo.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TrialInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TrialInfo = + TrialInfo( + checkRequired("endDate", endDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TrialInfo = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = + changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = + changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { + it.toImmutable() + }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Subscription{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeCancelResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionChangeCancelResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt new file mode 100644 index 00000000..91cf124c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects + +/** + * This endpoint returns a subscription change given an identifier. + * + * A subscription change is created by including `Create-Pending-Subscription-Change: True` in the + * header of a subscription mutation API call (e.g. + * [create subscription endpoint](/api-reference/subscription/create-subscription), [schedule plan + * change endpoint](/api-reference/subscription/schedule-plan-change), ...). The subscription change + * will be referenced by the `pending_subscription_change` field in the response. + */ +class SubscriptionChangeRetrieveParams +private constructor( + private val subscriptionChangeId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun subscriptionChangeId(): String = subscriptionChangeId + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeRetrieveParams]. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeRetrieveParams]. */ + class Builder internal constructor() { + + private var subscriptionChangeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionChangeRetrieveParams: SubscriptionChangeRetrieveParams) = + apply { + subscriptionChangeId = subscriptionChangeRetrieveParams.subscriptionChangeId + additionalHeaders = subscriptionChangeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + subscriptionChangeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun subscriptionChangeId(subscriptionChangeId: String) = apply { + this.subscriptionChangeId = subscriptionChangeId + } + + 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 [SubscriptionChangeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionChangeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeRetrieveParams = + SubscriptionChangeRetrieveParams( + checkRequired("subscriptionChangeId", subscriptionChangeId), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> subscriptionChangeId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeRetrieveParams && subscriptionChangeId == other.subscriptionChangeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(subscriptionChangeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SubscriptionChangeRetrieveParams{subscriptionChangeId=$subscriptionChangeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt new file mode 100644 index 00000000..41b9fa0b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt @@ -0,0 +1,11498 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A subscription change represents a desired new subscription / pending change to an existing + * subscription. It is a way to first preview the effects on the subscription as well as any + * changes/creation of invoices (see `subscription.changed_resources`). + */ +class SubscriptionChangeRetrieveResponse +private constructor( + private val id: JsonField, + private val expirationTime: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val appliedAt: JsonField, + private val cancelledAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("expiration_time") + @ExcludeMissing + expirationTime: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("applied_at") + @ExcludeMissing + appliedAt: JsonField = JsonMissing.of(), + @JsonProperty("cancelled_at") + @ExcludeMissing + cancelledAt: JsonField = JsonMissing.of(), + ) : this(id, expirationTime, status, subscription, appliedAt, cancelledAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Subscription change will be cancelled at this time and can no longer be applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun expirationTime(): OffsetDateTime = expirationTime.getRequired("expiration_time") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): Optional = subscription.getOptional("subscription") + + /** + * When this change was applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun appliedAt(): Optional = appliedAt.getOptional("applied_at") + + /** + * When this change was cancelled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun cancelledAt(): Optional = cancelledAt.getOptional("cancelled_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 [expirationTime]. + * + * Unlike [expirationTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiration_time") + @ExcludeMissing + fun _expirationTime(): JsonField = expirationTime + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [appliedAt]. + * + * Unlike [appliedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("applied_at") + @ExcludeMissing + fun _appliedAt(): JsonField = appliedAt + + /** + * Returns the raw JSON value of [cancelledAt]. + * + * Unlike [cancelledAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cancelled_at") + @ExcludeMissing + fun _cancelledAt(): JsonField = cancelledAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionChangeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionChangeRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var expirationTime: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var appliedAt: JsonField = JsonMissing.of() + private var cancelledAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionChangeRetrieveResponse: SubscriptionChangeRetrieveResponse) = + apply { + id = subscriptionChangeRetrieveResponse.id + expirationTime = subscriptionChangeRetrieveResponse.expirationTime + status = subscriptionChangeRetrieveResponse.status + subscription = subscriptionChangeRetrieveResponse.subscription + appliedAt = subscriptionChangeRetrieveResponse.appliedAt + cancelledAt = subscriptionChangeRetrieveResponse.cancelledAt + additionalProperties = + subscriptionChangeRetrieveResponse.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 } + + /** Subscription change will be cancelled at this time and can no longer be applied. */ + fun expirationTime(expirationTime: OffsetDateTime) = + expirationTime(JsonField.of(expirationTime)) + + /** + * Sets [Builder.expirationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.expirationTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expirationTime(expirationTime: JsonField) = apply { + this.expirationTime = expirationTime + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [Subscription] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** When this change was applied. */ + fun appliedAt(appliedAt: OffsetDateTime?) = appliedAt(JsonField.ofNullable(appliedAt)) + + /** Alias for calling [Builder.appliedAt] with `appliedAt.orElse(null)`. */ + fun appliedAt(appliedAt: Optional) = appliedAt(appliedAt.getOrNull()) + + /** + * Sets [Builder.appliedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.appliedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appliedAt(appliedAt: JsonField) = apply { this.appliedAt = appliedAt } + + /** When this change was cancelled. */ + fun cancelledAt(cancelledAt: OffsetDateTime?) = + cancelledAt(JsonField.ofNullable(cancelledAt)) + + /** Alias for calling [Builder.cancelledAt] with `cancelledAt.orElse(null)`. */ + fun cancelledAt(cancelledAt: Optional) = + cancelledAt(cancelledAt.getOrNull()) + + /** + * Sets [Builder.cancelledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.cancelledAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancelledAt(cancelledAt: JsonField) = apply { + this.cancelledAt = cancelledAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionChangeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .expirationTime() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionChangeRetrieveResponse = + SubscriptionChangeRetrieveResponse( + checkRequired("id", id), + checkRequired("expirationTime", expirationTime), + checkRequired("status", status), + checkRequired("subscription", subscription), + appliedAt, + cancelledAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubscriptionChangeRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + expirationTime() + status().validate() + subscription().ifPresent { it.validate() } + appliedAt() + cancelledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (expirationTime.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (appliedAt.asKnown().isPresent) 1 else 0) + + (if (cancelledAt.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val APPLIED = of("applied") + + @JvmField val CANCELLED = of("cancelled") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + APPLIED, + CANCELLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + APPLIED, + CANCELLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + APPLIED -> Value.APPLIED + CANCELLED -> Value.CANCELLED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + APPLIED -> Known.APPLIED + CANCELLED -> Known.CANCELLED + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Subscription + private constructor( + private val id: JsonField, + private val activePlanPhaseOrder: JsonField, + private val adjustmentIntervals: JsonField>, + private val autoCollection: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val billingCycleDay: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val customer: JsonField, + private val defaultInvoiceMemo: JsonField, + private val discountIntervals: JsonField>, + private val endDate: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val invoicingThreshold: JsonField, + private val maximumIntervals: JsonField>, + private val metadata: JsonField, + private val minimumIntervals: JsonField>, + private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, + private val plan: JsonField, + private val priceIntervals: JsonField>, + private val redeemedCoupon: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val changedResources: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + activePlanPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_intervals") + @ExcludeMissing + adjustmentIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("discount_intervals") + @ExcludeMissing + discountIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fixedFeeQuantitySchedule: JsonField> = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("maximum_intervals") + @ExcludeMissing + maximumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum_intervals") + @ExcludeMissing + minimumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), + @JsonProperty("price_intervals") + @ExcludeMissing + priceIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("redeemed_coupon") + @ExcludeMissing + redeemedCoupon: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("trial_info") + @ExcludeMissing + trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), + ) : this( + id, + activePlanPhaseOrder, + adjustmentIntervals, + autoCollection, + billingCycleAnchorConfiguration, + billingCycleDay, + createdAt, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + customer, + defaultInvoiceMemo, + discountIntervals, + endDate, + fixedFeeQuantitySchedule, + invoicingThreshold, + maximumIntervals, + metadata, + minimumIntervals, + netTerms, + pendingSubscriptionChange, + plan, + priceIntervals, + redeemedCoupon, + startDate, + status, + trialInfo, + changedResources, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The current plan phase that is active, only if the subscription's plan has phases. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun activePlanPhaseOrder(): Optional = + activePlanPhaseOrder.getOptional("active_plan_phase_order") + + /** + * The adjustment intervals for this subscription sorted by the start_date of the adjustment + * interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultInvoiceMemo(): Optional = + defaultInvoiceMemo.getOptional("default_invoice_memo") + + /** + * The discount intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** + * The date Orb stops billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingThreshold(): Optional = + invoicingThreshold.getOptional("invoicing_threshold") + + /** + * The maximum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maximumIntervals(): List = + maximumIntervals.getRequired("maximum_intervals") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * The minimum intervals for this subscription sorted by the start_date. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun plan(): Plan = plan.getRequired("plan") + + /** + * The price intervals for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun redeemedCoupon(): Optional = + redeemedCoupon.getOptional("redeemed_coupon") + + /** + * The date Orb starts billing for this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + + /** + * 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 [activePlanPhaseOrder]. + * + * Unlike [activePlanPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder + + /** + * Returns the raw JSON value of [adjustmentIntervals]. + * + * Unlike [adjustmentIntervals], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingCycleAnchorConfiguration]. + * + * Unlike [billingCycleAnchorConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [defaultInvoiceMemo]. + * + * Unlike [defaultInvoiceMemo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + /** + * Returns the raw JSON value of [discountIntervals]. + * + * Unlike [discountIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [fixedFeeQuantitySchedule]. + * + * Unlike [fixedFeeQuantitySchedule], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule + + /** + * Returns the raw JSON value of [invoicingThreshold]. + * + * Unlike [invoicingThreshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold + + /** + * Returns the raw JSON value of [maximumIntervals]. + * + * Unlike [maximumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimumIntervals]. + * + * Unlike [minimumIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals + + /** + * Returns the raw JSON value of [netTerms]. + * + * Unlike [netTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + + /** + * Returns the raw JSON value of [plan]. + * + * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** + * Returns the raw JSON value of [priceIntervals]. + * + * Unlike [priceIntervals], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals + + /** + * Returns the raw JSON value of [redeemedCoupon]. + * + * Unlike [redeemedCoupon], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [trialInfo]. + * + * Unlike [trialInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo + + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Subscription]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: + JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: + JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscription: Subscription) = apply { + id = subscription.id + activePlanPhaseOrder = subscription.activePlanPhaseOrder + adjustmentIntervals = subscription.adjustmentIntervals.map { it.toMutableList() } + autoCollection = subscription.autoCollection + billingCycleAnchorConfiguration = subscription.billingCycleAnchorConfiguration + billingCycleDay = subscription.billingCycleDay + createdAt = subscription.createdAt + currentBillingPeriodEndDate = subscription.currentBillingPeriodEndDate + currentBillingPeriodStartDate = subscription.currentBillingPeriodStartDate + customer = subscription.customer + defaultInvoiceMemo = subscription.defaultInvoiceMemo + discountIntervals = subscription.discountIntervals.map { it.toMutableList() } + endDate = subscription.endDate + fixedFeeQuantitySchedule = + subscription.fixedFeeQuantitySchedule.map { it.toMutableList() } + invoicingThreshold = subscription.invoicingThreshold + maximumIntervals = subscription.maximumIntervals.map { it.toMutableList() } + metadata = subscription.metadata + minimumIntervals = subscription.minimumIntervals.map { it.toMutableList() } + netTerms = subscription.netTerms + pendingSubscriptionChange = subscription.pendingSubscriptionChange + plan = subscription.plan + priceIntervals = subscription.priceIntervals.map { it.toMutableList() } + redeemedCoupon = subscription.redeemedCoupon + startDate = subscription.startDate + status = subscription.status + trialInfo = subscription.trialInfo + changedResources = subscription.changedResources + additionalProperties = subscription.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 current plan phase that is active, only if the subscription's plan has phases. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + + /** + * Alias for [Builder.activePlanPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** + * Alias for calling [Builder.activePlanPhaseOrder] with + * `activePlanPhaseOrder.orElse(null)`. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.getOrNull()) + + /** + * Sets [Builder.activePlanPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.activePlanPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + /** + * The adjustment intervals for this subscription sorted by the start_date of the + * adjustment interval. + */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** + * Sets [Builder.adjustmentIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [AdjustmentInterval] to [adjustmentIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. This property defaults to the + * plan's behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + /** + * Sets [Builder.billingCycleAnchorConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleAnchorConfiguration] with a well-typed + * [BillingCycleAnchorConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions + * that are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if the + * subscription is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * A customer is a buyer of your products, and the other party to the billing + * relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's + * often desirable to have these match existing identifiers in your system. To avoid + * having to denormalize Orb ID information, you can pass in an `external_customer_id` + * with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information + * about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the + * `payment_provider` enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for + * information on what this timezone parameter influences within Orb. + */ + fun customer(customer: Customer) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [Customer] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Alias for calling [Builder.defaultInvoiceMemo] with + * `defaultInvoiceMemo.orElse(null)`. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.getOrNull()) + + /** + * Sets [Builder.defaultInvoiceMemo] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultInvoiceMemo] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** The discount intervals for this subscription sorted by the start_date. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** + * Sets [Builder.discountIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.discountIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountInterval] to [discountIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) + } + } + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ + fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + addDiscountInterval(DiscountInterval.ofAmount(amount)) + + /** + * Alias for calling [addDiscountInterval] with + * `DiscountInterval.ofPercentage(percentage)`. + */ + fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofPercentage(percentage)) + + /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ + fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + addDiscountInterval(DiscountInterval.ofUsage(usage)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + /** + * Sets [Builder.fixedFeeQuantitySchedule] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantitySchedule] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantitySchedule] to [Builder.fixedFeeQuantitySchedule]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + /** + * Alias for calling [Builder.invoicingThreshold] with + * `invoicingThreshold.orElse(null)`. + */ + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.getOrNull()) + + /** + * Sets [Builder.invoicingThreshold] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingThreshold] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The maximum intervals for this subscription sorted by the start_date. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** + * Sets [Builder.maximumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MaximumInterval] to [maximumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) + } + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** The minimum intervals for this subscription sorted by the start_date. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** + * Sets [Builder.minimumIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [MinimumInterval] to [minimumIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) + } + } + + /** + * Determines the difference between the invoice issue date for subscription invoices as + * the date that they are due. A value of `0` here represents that the invoice is due on + * issue, whereas a value of `30` represents that the customer has a month to pay the + * invoice. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Sets [Builder.netTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.netTerms] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. + * You can see more about how to configure prices in the + * [Price resource](/reference/price). + */ + fun plan(plan: Plan) = plan(JsonField.of(plan)) + + /** + * Sets [Builder.plan] to an arbitrary JSON value. + * + * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun plan(plan: JsonField) = apply { this.plan = plan } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** + * Sets [Builder.priceIntervals] to an arbitrary JSON value. + * + * You should usually call [Builder.priceIntervals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** + * Adds a single [PriceInterval] to [priceIntervals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + /** Alias for calling [Builder.redeemedCoupon] with `redeemedCoupon.orElse(null)`. */ + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.getOrNull()) + + /** + * Sets [Builder.redeemedCoupon] to an arbitrary JSON value. + * + * You should usually call [Builder.redeemedCoupon] with a well-typed [RedeemedCoupon] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + /** + * Sets [Builder.trialInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.trialInfo] with a well-typed [TrialInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter + * was passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** + * Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. + */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed + * [ChangedResources] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + 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 + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .pendingSubscriptionChange() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Subscription = + Subscription( + checkRequired("id", id), + checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), + checkRequired("adjustmentIntervals", adjustmentIntervals).map { + it.toImmutable() + }, + checkRequired("autoCollection", autoCollection), + checkRequired( + "billingCycleAnchorConfiguration", + billingCycleAnchorConfiguration, + ), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("createdAt", createdAt), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("customer", customer), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, + checkRequired("endDate", endDate), + checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { + it.toImmutable() + }, + checkRequired("invoicingThreshold", invoicingThreshold), + checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, + checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), + checkRequired("plan", plan), + checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, + checkRequired("redeemedCoupon", redeemedCoupon), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("trialInfo", trialInfo), + changedResources, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Subscription = apply { + if (validated) { + return@apply + } + + id() + activePlanPhaseOrder() + adjustmentIntervals().forEach { it.validate() } + autoCollection() + billingCycleAnchorConfiguration().validate() + billingCycleDay() + createdAt() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + customer().validate() + defaultInvoiceMemo() + discountIntervals().forEach { it.validate() } + endDate() + fixedFeeQuantitySchedule().forEach { it.validate() } + invoicingThreshold() + maximumIntervals().forEach { it.validate() } + metadata().validate() + minimumIntervals().forEach { it.validate() } + netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } + plan().validate() + priceIntervals().forEach { it.validate() } + redeemedCoupon().ifPresent { it.validate() } + startDate() + status().validate() + trialInfo().validate() + changedResources().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (activePlanPhaseOrder.asKnown().isPresent) 1 else 0) + + (adjustmentIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (billingCycleAnchorConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (discountIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantitySchedule.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (invoicingThreshold.asKnown().isPresent) 1 else 0) + + (maximumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) + + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The price interval IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the adjustment interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * 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 [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AdjustmentInterval]. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdjustmentInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + id = adjustmentInterval.id + adjustment = adjustmentInterval.adjustment + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = adjustmentInterval.endDate + startDate = adjustmentInterval.startDate + additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + */ + fun adjustment( + planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + */ + fun adjustment( + planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment + ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + */ + fun adjustment( + planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment + ) = + adjustment( + Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) + ) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. + */ + fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. + */ + fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = + adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AdjustmentInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AdjustmentInterval = + AdjustmentInterval( + checkRequired("id", id), + checkRequired("adjustment", adjustment), + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdjustmentInterval = apply { + if (validated) { + return@apply + } + + id() + adjustment().validate() + appliesToPriceIntervalIds() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, + private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, + private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = + null, + private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, + private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + fun planPhaseUsageDiscount(): Optional = + Optional.ofNullable(planPhaseUsageDiscount) + + fun planPhaseAmountDiscount(): Optional = + Optional.ofNullable(planPhaseAmountDiscount) + + fun planPhasePercentageDiscount(): Optional = + Optional.ofNullable(planPhasePercentageDiscount) + + fun planPhaseMinimum(): Optional = + Optional.ofNullable(planPhaseMinimum) + + fun planPhaseMaximum(): Optional = + Optional.ofNullable(planPhaseMaximum) + + fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + + fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + + fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + + fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + + fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + + fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = + planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + + fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = + planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + + fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = + planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + + fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = + planPhaseMinimum.getOrThrow("planPhaseMinimum") + + fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = + planPhaseMaximum.getOrThrow("planPhaseMaximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + planPhaseUsageDiscount != null -> + visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) + planPhaseAmountDiscount != null -> + visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) + planPhasePercentageDiscount != null -> + visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) + planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) + planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) { + planPhaseUsageDiscount.validate() + } + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) { + planPhaseAmountDiscount.validate() + } + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) { + planPhasePercentageDiscount.validate() + } + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) { + planPhaseMinimum.validate() + } + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) { + planPhaseMaximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = planPhaseUsageDiscount.validity() + + override fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = planPhaseAmountDiscount.validity() + + override fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = planPhasePercentageDiscount.validity() + + override fun visitPlanPhaseMinimum( + planPhaseMinimum: PlanPhaseMinimumAdjustment + ) = planPhaseMinimum.validity() + + override fun visitPlanPhaseMaximum( + planPhaseMaximum: PlanPhaseMaximumAdjustment + ) = planPhaseMaximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + + override fun toString(): String = + when { + planPhaseUsageDiscount != null -> + "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" + planPhaseAmountDiscount != null -> + "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" + planPhasePercentageDiscount != null -> + "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" + planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" + planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + + @JvmStatic + fun ofPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + + @JvmStatic + fun ofPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + + @JvmStatic + fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = + Adjustment(planPhaseMinimum = planPhaseMinimum) + + @JvmStatic + fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = + Adjustment(planPhaseMaximum = planPhaseMaximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of + * type [T]. + */ + interface Visitor { + + fun visitPlanPhaseUsageDiscount( + planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment + ): T + + fun visitPlanPhaseAmountDiscount( + planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment + ): T + + fun visitPlanPhasePercentageDiscount( + planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + ): T + + fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + + fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json + .asObject() + .getOrNull() + ?.get("adjustment_type") + ?.asString() + ?.getOrNull() + + when (adjustmentType) { + "usage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "percentage_discount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Adjustment(planPhasePercentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMinimum = it, _json = json) } + ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Adjustment(planPhaseMaximum = it, _json = json) } + ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.planPhaseUsageDiscount != null -> + generator.writeObject(value.planPhaseUsageDiscount) + value.planPhaseAmountDiscount != null -> + generator.writeObject(value.planPhaseAmountDiscount) + value.planPhasePercentageDiscount != null -> + generator.writeObject(value.planPhasePercentageDiscount) + value.planPhaseMinimum != null -> + generator.writeObject(value.planPhaseMinimum) + value.planPhaseMaximum != null -> + generator.writeObject(value.planPhaseMaximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + class PlanPhaseUsageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + usageDiscount, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseUsageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ) = apply { + id = planPhaseUsageDiscountAdjustment.id + adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder + reason = planPhaseUsageDiscountAdjustment.reason + usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount + additionalProperties = + planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** + * The number of usage units by which to discount the price this adjustment + * applies to in a given billing period. + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseUsageDiscountAdjustment = + PlanPhaseUsageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_DISCOUNT = of("usage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + USAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + class PlanPhaseAmountDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + amountDiscount, + appliesToPriceIds, + isInvoiceLevel, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The amount by which to discount the prices this adjustment applies to in a + * given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseAmountDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) = apply { + id = planPhaseAmountDiscountAdjustment.id + adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType + amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + appliesToPriceIds = + planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder + reason = planPhaseAmountDiscountAdjustment.reason + additionalProperties = + planPhaseAmountDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * The amount by which to discount the prices this adjustment applies to in + * a given billing period. + */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseAmountDiscountAdjustment = + PlanPhaseAmountDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT_DISCOUNT = of("amount_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + AMOUNT_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhasePercentageDiscountAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val percentageDiscount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + percentageDiscount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The percentage (as a value between 0 and 1) by which to discount the price + * intervals this adjustment applies to in a given billing period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhasePercentageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhasePercentageDiscountAdjustment: + PlanPhasePercentageDiscountAdjustment + ) = apply { + id = planPhasePercentageDiscountAdjustment.id + adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel + percentageDiscount = + planPhasePercentageDiscountAdjustment.percentageDiscount + planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder + reason = planPhasePercentageDiscountAdjustment.reason + additionalProperties = + planPhasePercentageDiscountAdjustment.additionalProperties + .toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The percentage (as a value between 0 and 1) by which to discount the + * price intervals this adjustment applies to in a given billing period. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhasePercentageDiscountAdjustment = + PlanPhasePercentageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + percentageDiscount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + PERCENTAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMinimumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val itemId: JsonField, + private val minimumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + itemId, + minimumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The item ID that revenue from this minimum will be attributed to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("item_id") + @ExcludeMissing + fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMinimumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMinimumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = + apply { + id = planPhaseMinimumAdjustment.id + adjustmentType = planPhaseMinimumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMinimumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel + itemId = planPhaseMinimumAdjustment.itemId + minimumAmount = planPhaseMinimumAdjustment.minimumAmount + planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder + reason = planPhaseMinimumAdjustment.reason + additionalProperties = + planPhaseMinimumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The minimum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMinimumAdjustment = + PlanPhaseMinimumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("itemId", itemId), + checkRequired("minimumAmount", minimumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMinimumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + itemId() + minimumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MINIMUM = of("minimum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + class PlanPhaseMaximumAdjustment + private constructor( + private val id: JsonField, + private val adjustmentType: JsonField, + private val appliesToPriceIds: JsonField>, + private val isInvoiceLevel: JsonField, + private val maximumAmount: JsonField, + private val planPhaseOrder: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + id, + adjustmentType, + appliesToPriceIds, + isInvoiceLevel, + maximumAmount, + planPhaseOrder, + reason, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun adjustmentType(): AdjustmentType = + adjustmentType.getRequired("adjustment_type") + + /** + * The price IDs that this adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments + * that apply to only one price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The plan phase in which this adjustment is active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = + planPhaseOrder.getOptional("plan_phase_order") + + /** + * The reason for the adjustment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * 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 [adjustmentType]. + * + * Unlike [adjustmentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [isInvoiceLevel]. + * + * Unlike [isInvoiceLevel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMaximumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMaximumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = + apply { + id = planPhaseMaximumAdjustment.id + adjustmentType = planPhaseMaximumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMaximumAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel + maximumAmount = planPhaseMaximumAdjustment.maximumAmount + planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder + reason = planPhaseMaximumAdjustment.reason + additionalProperties = + planPhaseMaximumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + /** + * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentType] with a well-typed + * [AdjustmentType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for + * adjustments that apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * Sets [Builder.isInvoiceLevel] to an arbitrary JSON value. + * + * You should usually call [Builder.isInvoiceLevel] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The maximum amount to charge in a given billing period for the prices + * this adjustment applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = + planPhaseOrder(planPhaseOrder as Long?) + + /** + * Alias for calling [Builder.planPhaseOrder] with + * `planPhaseOrder.orElse(null)`. + */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PlanPhaseMaximumAdjustment = + PlanPhaseMaximumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("maximumAmount", maximumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PlanPhaseMaximumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType().validate() + appliesToPriceIds() + isInvoiceLevel() + maximumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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) + + (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MAXIMUM = of("maximum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MAXIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAXIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> + throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AdjustmentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day") @ExcludeMissing day: JsonField = JsonMissing.of(), + @JsonProperty("month") @ExcludeMissing month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing year: JsonField = JsonMissing.of(), + ) : this(day, month, year, mutableMapOf()) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun day(): Long = day.getRequired("day") + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun month(): Optional = month.getOptional("month") + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun year(): Optional = year.getOptional("year") + + /** + * Returns the raw JSON value of [day]. + * + * Unlike [day], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day + + /** + * Returns the raw JSON value of [month]. + * + * Unlike [month], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * Returns the raw JSON value of [year]. + * + * Unlike [year], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BillingCycleAnchorConfiguration]. + * + * The following fields are required: + * ```java + * .day() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleAnchorConfiguration]. */ + class Builder internal constructor() { + + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = apply { + day = billingCycleAnchorConfiguration.day + month = billingCycleAnchorConfiguration.month + year = billingCycleAnchorConfiguration.year + additionalProperties = + billingCycleAnchorConfiguration.additionalProperties.toMutableMap() + } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum + * number of days in a month is greater than this value, the last day of the month + * is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing + * period begins on the 30th. + */ + fun day(day: Long) = day(JsonField.of(day)) + + /** + * Sets [Builder.day] to an arbitrary JSON value. + * + * You should usually call [Builder.day] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun day(day: JsonField) = apply { this.day = day } + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored + * in February would have cycles starting February, May, August, and November). + */ + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * Alias for [Builder.month]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun month(month: Long) = month(month as Long?) + + /** Alias for calling [Builder.month] with `month.orElse(null)`. */ + fun month(month: Optional) = month(month.getOrNull()) + + /** + * Sets [Builder.month] to an arbitrary JSON value. + * + * You should usually call [Builder.month] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun month(month: JsonField) = apply { this.month = month } + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle + * anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * Alias for [Builder.year]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun year(year: Long) = year(year as Long?) + + /** Alias for calling [Builder.year] with `year.orElse(null)`. */ + fun year(year: Optional) = year(year.getOrNull()) + + /** + * Sets [Builder.year] to an arbitrary JSON value. + * + * You should usually call [Builder.year] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BillingCycleAnchorConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .day() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + checkRequired("day", day), + month, + year, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (validated) { + return@apply + } + + day() + month() + year() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (day.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (if (year.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval + private constructor( + private val amount: AmountDiscountInterval? = null, + private val percentage: PercentageDiscountInterval? = null, + private val usage: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + fun amount(): Optional = Optional.ofNullable(amount) + + fun percentage(): Optional = Optional.ofNullable(percentage) + + fun usage(): Optional = Optional.ofNullable(usage) + + fun isAmount(): Boolean = amount != null + + fun isPercentage(): Boolean = percentage != null + + fun isUsage(): Boolean = usage != null + + fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + + fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + + fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + amount != null -> visitor.visitAmount(amount) + percentage != null -> visitor.visitPercentage(percentage) + usage != null -> visitor.visitUsage(usage) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DiscountInterval = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) { + amount.validate() + } + + override fun visitPercentage(percentage: PercentageDiscountInterval) { + percentage.validate() + } + + override fun visitUsage(usage: UsageDiscountInterval) { + usage.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + + override fun visitPercentage(percentage: PercentageDiscountInterval) = + percentage.validity() + + override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ + + override fun toString(): String = + when { + amount != null -> "DiscountInterval{amount=$amount}" + percentage != null -> "DiscountInterval{percentage=$percentage}" + usage != null -> "DiscountInterval{usage=$usage}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + + companion object { + + @JvmStatic + fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + + @JvmStatic + fun ofPercentage(percentage: PercentageDiscountInterval) = + DiscountInterval(percentage = percentage) + + @JvmStatic + fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + } + + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAmount(amount: AmountDiscountInterval): T + + fun visitPercentage(percentage: PercentageDiscountInterval): T + + fun visitUsage(usage: UsageDiscountInterval): T + + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + internal class Deserializer : + BaseDeserializer(DiscountInterval::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(amount = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "percentage" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { DiscountInterval(percentage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + "usage" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { DiscountInterval(usage = it, _json = json) } + ?: DiscountInterval(_json = json) + } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amount != null -> generator.writeObject(value.amount) + value.percentage != null -> generator.writeObject(value.percentage) + value.usage != null -> generator.writeObject(value.usage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + class AmountDiscountInterval + private constructor( + private val amountDiscount: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount_discount") + @ExcludeMissing + amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + amountDiscount, + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * Only available if discount_type is `amount`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [amountDiscount]. + * + * Unlike [amountDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AmountDiscountInterval]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AmountDiscountInterval]. */ + class Builder internal constructor() { + + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + amountDiscount = amountDiscountInterval.amountDiscount + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = amountDiscountInterval.discountType + endDate = amountDiscountInterval.endDate + startDate = amountDiscountInterval.startDate + additionalProperties = + amountDiscountInterval.additionalProperties.toMutableMap() + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * Sets [Builder.amountDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDiscount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AmountDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AmountDiscountInterval = apply { + if (validated) { + return@apply + } + + amountDiscount() + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amountDiscount.asKnown().isPresent) 1 else 0) + + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + AMOUNT + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class PercentageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + percentageDiscount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Only available if discount_type is `percentage`.This is a number between 0 and 1. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = + apply { + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { + it.toMutableList() + } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = percentageDiscountInterval.discountType + endDate = percentageDiscountInterval.endDate + percentageDiscount = percentageDiscountInterval.percentageDiscount + startDate = percentageDiscountInterval.startDate + additionalProperties = + percentageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** + * Only available if discount_type is `percentage`.This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + percentageDiscount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class UsageDiscountInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val discountType: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + usageDiscount: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + discountType, + endDate, + startDate, + usageDiscount, + mutableMapOf(), + ) + + /** + * The price ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this discount interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * The end date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the discount interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = + appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [discountType]. + * + * Unlike [discountType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageDiscount]. + * + * Unlike [usageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UsageDiscountInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageDiscountInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = usageDiscountInterval.discountType + endDate = usageDiscountInterval.endDate + startDate = usageDiscountInterval.startDate + usageDiscount = usageDiscountInterval.usageDiscount + additionalProperties = + usageDiscountInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds( + appliesToPriceIntervalIds: JsonField> + ) = apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + /** + * Sets [Builder.discountType] to an arbitrary JSON value. + * + * You should usually call [Builder.discountType] with a well-typed + * [DiscountType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { + this.endDate = endDate + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Sets [Builder.usageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.usageDiscount] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageDiscountInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) + .map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageDiscountInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType().validate() + endDate() + startDate() + usageDiscount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (discountType.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (usageDiscount.asKnown().isPresent) 1 else 0) + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE = of("usage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + USAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DiscountType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + } + + class FixedFeeQuantitySchedule + private constructor( + private val endDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(endDate, priceId, quantity, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FixedFeeQuantitySchedule]. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantitySchedule]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + endDate = fixedFeeQuantitySchedule.endDate + priceId = fixedFeeQuantitySchedule.priceId + quantity = fixedFeeQuantitySchedule.quantity + startDate = fixedFeeQuantitySchedule.startDate + additionalProperties = + fixedFeeQuantitySchedule.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + 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 startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedFeeQuantitySchedule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + checkRequired("endDate", endDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantitySchedule = apply { + if (validated) { + return@apply + } + + endDate() + priceId() + quantity() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class MaximumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val maximumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + maximumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this maximum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * The start date of the maximum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MaximumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = maximumInterval.endDate + maximumAmount = maximumInterval.maximumAmount + startDate = maximumInterval.startDate + additionalProperties = maximumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The maximum amount to charge in a given billing period for the price intervals + * this transform applies to. + */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaximumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumInterval = + MaximumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("maximumAmount", maximumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + maximumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class MinimumInterval + private constructor( + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val endDate: JsonField, + private val minimumAmount: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + appliesToPriceIds, + appliesToPriceIntervalIds, + endDate, + minimumAmount, + startDate, + mutableMapOf(), + ) + + /** + * The price ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * The price interval ids that this minimum interval applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** + * The end date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * The start date of the minimum interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [appliesToPriceIds]. + * + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * Returns the raw JSON value of [appliesToPriceIntervalIds]. + * + * Unlike [appliesToPriceIntervalIds], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumInterval]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumInterval]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = minimumInterval.endDate + minimumAmount = minimumInterval.minimumAmount + startDate = minimumInterval.startDate + additionalProperties = minimumInterval.additionalProperties.toMutableMap() + } + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * Sets [Builder.appliesToPriceIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** + * Sets [Builder.appliesToPriceIntervalIds] to an arbitrary JSON value. + * + * You should usually call [Builder.appliesToPriceIntervalIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [appliesToPriceIntervalIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it) + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The minimum amount to charge in a given billing period for the price intervals + * this minimum applies to. + */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumInterval = + MinimumInterval( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("minimumAmount", minimumAmount), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumInterval = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + minimumAmount() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = + pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + + /** + * The Price Interval resource represents a period of time for which a price will bill on a + * subscription. A subscription’s price intervals define its billing behavior. + */ + class PriceInterval + private constructor( + private val id: JsonField, + private val billingCycleDay: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val endDate: JsonField, + private val filter: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val price: JsonField, + private val startDate: JsonField, + private val usageCustomerIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_customer_ids") + @ExcludeMissing + usageCustomerIds: JsonField> = JsonMissing.of(), + ) : this( + id, + billingCycleDay, + currentBillingPeriodEndDate, + currentBillingPeriodStartDate, + endDate, + filter, + fixedFeeQuantityTransitions, + price, + startDate, + usageCustomerIds, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The day of the month that Orb bills for this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodEndDate(): Optional = + currentBillingPeriodEndDate.getOptional("current_billing_period_end_date") + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currentBillingPeriodStartDate(): Optional = + currentBillingPeriodStartDate.getOptional("current_billing_period_start_date") + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * An additional filter to apply to usage queries. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedFeeQuantityTransitions(): Optional> = + fixedFeeQuantityTransitions.getOptional("fixed_fee_quantity_transitions") + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun price(): Price = price.getRequired("price") + + /** + * The start date of the price interval. This is the date that Orb starts billing for + * this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this + * price interval. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usageCustomerIds(): Optional> = + usageCustomerIds.getOptional("usage_customer_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 + + /** + * Returns the raw JSON value of [billingCycleDay]. + * + * Unlike [billingCycleDay], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * Returns the raw JSON value of [currentBillingPeriodEndDate]. + * + * Unlike [currentBillingPeriodEndDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = + currentBillingPeriodEndDate + + /** + * Returns the raw JSON value of [currentBillingPeriodStartDate]. + * + * Unlike [currentBillingPeriodStartDate], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [fixedFeeQuantityTransitions]. + * + * Unlike [fixedFeeQuantityTransitions], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [usageCustomerIds]. + * + * Unlike [usageCustomerIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usage_customer_ids") + @ExcludeMissing + fun _usageCustomerIds(): JsonField> = usageCustomerIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceInterval]. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceInterval]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var filter: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null + private var usageCustomerIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + id = priceInterval.id + billingCycleDay = priceInterval.billingCycleDay + currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + endDate = priceInterval.endDate + filter = priceInterval.filter + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } + price = priceInterval.price + startDate = priceInterval.startDate + usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + additionalProperties = priceInterval.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * 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 day of the month that Orb bills for this price */ + fun billingCycleDay(billingCycleDay: Long) = + billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * Sets [Builder.billingCycleDay] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleDay] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that + * the instant returned is exactly the end of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * Alias for calling [Builder.currentBillingPeriodEndDate] with + * `currentBillingPeriodEndDate.orElse(null)`. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: Optional + ) = currentBillingPeriodEndDate(currentBillingPeriodEndDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if + * this price interval is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate( + JsonField.ofNullable(currentBillingPeriodStartDate) + ) + + /** + * Alias for calling [Builder.currentBillingPeriodStartDate] with + * `currentBillingPeriodStartDate.orElse(null)`. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.getOrNull()) + + /** + * Sets [Builder.currentBillingPeriodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.currentBillingPeriodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * The end date of the price interval. This is the date that Orb stops billing for + * this price. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** An additional filter to apply to usage queries. */ + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant + * for fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * Alias for calling [Builder.fixedFeeQuantityTransitions] with + * `fixedFeeQuantityTransitions.orElse(null)`. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.getOrNull()) + + /** + * Sets [Builder.fixedFeeQuantityTransitions] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedFeeQuantityTransitions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * Adds a single [FixedFeeQuantityTransition] to [fixedFeeQuantityTransitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) + .add(fixedFeeQuantityTransition) + } + } + + /** + * The Price resource represents a price that can be billed on a subscription, + * resulting in a charge on an invoice in the form of an invoice line item. Prices + * take a quantity and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models + * is serialized differently in a given Price object. The model_type field + * determines the key for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: Price) = price(JsonField.of(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + + /** + * Alias for calling [price] with + * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** + * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. + */ + fun price(unitWithProration: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** + * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. + */ + fun price(groupedAllocation: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. + */ + fun price(bulkWithProration: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * The start date of the price interval. This is the date that Orb starts billing + * for this price. + */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * A list of customer IDs whose usage events will be aggregated and billed under + * this price interval. + */ + fun usageCustomerIds(usageCustomerIds: List?) = + usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) + + /** + * Alias for calling [Builder.usageCustomerIds] with + * `usageCustomerIds.orElse(null)`. + */ + fun usageCustomerIds(usageCustomerIds: Optional>) = + usageCustomerIds(usageCustomerIds.getOrNull()) + + /** + * Sets [Builder.usageCustomerIds] to an arbitrary JSON value. + * + * You should usually call [Builder.usageCustomerIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { + this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [usageCustomerIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUsageCustomerId(usageCustomerId: String) = apply { + usageCustomerIds = + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PriceInterval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceInterval = + PriceInterval( + checkRequired("id", id), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired( + "currentBillingPeriodStartDate", + currentBillingPeriodStartDate, + ), + checkRequired("endDate", endDate), + checkRequired("filter", filter), + checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions) + .map { it.toImmutable() }, + checkRequired("price", price), + checkRequired("startDate", startDate), + checkRequired("usageCustomerIds", usageCustomerIds).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PriceInterval = apply { + if (validated) { + return@apply + } + + id() + billingCycleDay() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + endDate() + filter() + fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + price().validate() + startDate() + usageCustomerIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a 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 (billingCycleDay.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodEndDate.asKnown().isPresent) 1 else 0) + + (if (currentBillingPeriodStartDate.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + class FixedFeeQuantityTransition + private constructor( + private val effectiveDate: JsonField, + private val priceId: JsonField, + private val quantity: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(effectiveDate, priceId, quantity, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_id") + @ExcludeMissing + fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [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 + * [FixedFeeQuantityTransition]. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantityTransition]. */ + class Builder internal constructor() { + + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = + apply { + effectiveDate = fixedFeeQuantityTransition.effectiveDate + priceId = fixedFeeQuantityTransition.priceId + quantity = fixedFeeQuantityTransition.quantity + additionalProperties = + fixedFeeQuantityTransition.additionalProperties.toMutableMap() + } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Long] 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 [FixedFeeQuantityTransition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + checkRequired("effectiveDate", effectiveDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (validated) { + return@apply + } + + effectiveDate() + priceId() + quantity() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } + + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("coupon_id") + @ExcludeMissing + couponId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(couponId, endDate, startDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun couponId(): String = couponId.getRequired("coupon_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Returns the raw JSON value of [couponId]. + * + * Unlike [couponId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RedeemedCoupon]. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RedeemedCoupon]. */ + class Builder internal constructor() { + + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + couponId = redeemedCoupon.couponId + endDate = redeemedCoupon.endDate + startDate = redeemedCoupon.startDate + additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + /** + * Sets [Builder.couponId] to an arbitrary JSON value. + * + * You should usually call [Builder.couponId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RedeemedCoupon]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RedeemedCoupon = + RedeemedCoupon( + checkRequired("couponId", couponId), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RedeemedCoupon = apply { + if (validated) { + return@apply + } + + couponId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (couponId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val ENDED = of("ended") + + @JvmField val UPCOMING = of("upcoming") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TrialInfo]. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrialInfo]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + endDate = trialInfo.endDate + additionalProperties = trialInfo.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TrialInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TrialInfo = + TrialInfo( + checkRequired("endDate", endDate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TrialInfo = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = + changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = + changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { + it.toImmutable() + }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Subscription && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Subscription{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionChangeRetrieveResponse && id == other.id && expirationTime == other.expirationTime && status == other.status && subscription == other.subscription && appliedAt == other.appliedAt && cancelledAt == other.cancelledAt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, expirationTime, status, subscription, appliedAt, cancelledAt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionChangeRetrieveResponse{id=$id, expirationTime=$expirationTime, status=$status, subscription=$subscription, appliedAt=$appliedAt, cancelledAt=$cancelledAt, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 349b052d..61e514f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -18208,7 +18208,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -18226,7 +18226,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -18306,7 +18306,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -18336,7 +18336,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last + * Inclusive tier ending value. If null, this is treated as the last * tier */ fun lastUnit(lastUnit: Double?) = @@ -20771,7 +20771,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -20780,7 +20780,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -20892,7 +20892,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -20907,7 +20907,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -82252,7 +82252,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -82270,7 +82270,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -82350,7 +82350,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -82380,7 +82380,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last + * Inclusive tier ending value. If null, this is treated as the last * tier */ fun lastUnit(lastUnit: Double?) = @@ -84815,7 +84815,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -84824,7 +84824,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -84936,7 +84936,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -84951,7 +84951,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt index 36db1486..fc804d4c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -642,6 +693,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -677,12 +729,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -712,12 +766,14 @@ private constructor( minimumIntervals = subscriptionCreateResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionCreateResponse.netTerms + pendingSubscriptionChange = subscriptionCreateResponse.pendingSubscriptionChange plan = subscriptionCreateResponse.plan priceIntervals = subscriptionCreateResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionCreateResponse.redeemedCoupon startDate = subscriptionCreateResponse.startDate status = subscriptionCreateResponse.status trialInfo = subscriptionCreateResponse.trialInfo + changedResources = subscriptionCreateResponse.changedResources additionalProperties = subscriptionCreateResponse.additionalProperties.toMutableMap() } @@ -1162,6 +1218,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1255,6 +1334,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1300,6 +1402,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1333,12 +1436,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1369,12 +1474,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1412,12 +1519,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8504,6 +8613,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10088,20 +10354,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionCreateResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionCreateResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionCreateResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionCreateResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index b049da38..923ad5f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -16653,7 +16653,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -16671,7 +16671,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -16751,7 +16751,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -16781,7 +16781,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last + * Inclusive tier ending value. If null, this is treated as the last * tier */ fun lastUnit(lastUnit: Double?) = @@ -19160,7 +19160,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -19169,7 +19169,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -19281,7 +19281,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -19296,7 +19296,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt index acb69dba..795bbc12 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -720,6 +774,8 @@ private constructor( minimumIntervals = subscriptionPriceIntervalsResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionPriceIntervalsResponse.netTerms + pendingSubscriptionChange = + subscriptionPriceIntervalsResponse.pendingSubscriptionChange plan = subscriptionPriceIntervalsResponse.plan priceIntervals = subscriptionPriceIntervalsResponse.priceIntervals.map { it.toMutableList() } @@ -727,6 +783,7 @@ private constructor( startDate = subscriptionPriceIntervalsResponse.startDate status = subscriptionPriceIntervalsResponse.status trialInfo = subscriptionPriceIntervalsResponse.trialInfo + changedResources = subscriptionPriceIntervalsResponse.changedResources additionalProperties = subscriptionPriceIntervalsResponse.additionalProperties.toMutableMap() } @@ -1172,6 +1229,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1265,6 +1345,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1310,6 +1413,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1343,12 +1447,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1379,12 +1485,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1422,12 +1530,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8514,6 +8624,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10098,20 +10365,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionPriceIntervalsResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionPriceIntervalsResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionPriceIntervalsResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionPriceIntervalsResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index bf3d5f0a..851d0151 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -17975,7 +17975,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -17993,7 +17993,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -18073,7 +18073,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -18103,7 +18103,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last + * Inclusive tier ending value. If null, this is treated as the last * tier */ fun lastUnit(lastUnit: Double?) = @@ -20538,7 +20538,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -20547,7 +20547,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -20659,7 +20659,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -20674,7 +20674,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -81917,7 +81917,7 @@ private constructor( ) : this(firstUnit, unitAmount, lastUnit, mutableMapOf()) /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -81935,7 +81935,7 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Exclusive tier ending value. If null, this is treated as the last tier + * Inclusive tier ending value. If null, this is treated as the last tier * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -82015,7 +82015,7 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) /** @@ -82045,7 +82045,7 @@ private constructor( } /** - * Exclusive tier ending value. If null, this is treated as the last + * Inclusive tier ending value. If null, this is treated as the last * tier */ fun lastUnit(lastUnit: Double?) = @@ -84480,7 +84480,7 @@ private constructor( fun bps(): Double = bps.getRequired("bps") /** - * Inclusive tier starting value + * Exclusive tier starting value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with @@ -84489,7 +84489,7 @@ private constructor( fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * Exclusive tier ending value + * Inclusive tier ending value * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -84601,7 +84601,7 @@ private constructor( */ fun bps(bps: JsonField) = apply { this.bps = bps } - /** Inclusive tier starting value */ + /** Exclusive tier starting value */ fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) @@ -84616,7 +84616,7 @@ private constructor( this.minimumAmount = minimumAmount } - /** Exclusive tier ending value */ + /** Inclusive tier ending value */ fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt index d80b3ad2..f105c093 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -721,6 +775,8 @@ private constructor( minimumIntervals = subscriptionSchedulePlanChangeResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionSchedulePlanChangeResponse.netTerms + pendingSubscriptionChange = + subscriptionSchedulePlanChangeResponse.pendingSubscriptionChange plan = subscriptionSchedulePlanChangeResponse.plan priceIntervals = subscriptionSchedulePlanChangeResponse.priceIntervals.map { it.toMutableList() } @@ -728,6 +784,7 @@ private constructor( startDate = subscriptionSchedulePlanChangeResponse.startDate status = subscriptionSchedulePlanChangeResponse.status trialInfo = subscriptionSchedulePlanChangeResponse.trialInfo + changedResources = subscriptionSchedulePlanChangeResponse.changedResources additionalProperties = subscriptionSchedulePlanChangeResponse.additionalProperties.toMutableMap() } @@ -1173,6 +1230,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1266,6 +1346,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1311,6 +1414,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1344,12 +1448,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1380,12 +1486,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1423,12 +1531,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8515,6 +8625,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10099,20 +10366,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionSchedulePlanChangeResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionSchedulePlanChangeResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionSchedulePlanChangeResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionSchedulePlanChangeResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt index ab894c10..b2206c15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -718,6 +772,8 @@ private constructor( minimumIntervals = subscriptionTriggerPhaseResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionTriggerPhaseResponse.netTerms + pendingSubscriptionChange = + subscriptionTriggerPhaseResponse.pendingSubscriptionChange plan = subscriptionTriggerPhaseResponse.plan priceIntervals = subscriptionTriggerPhaseResponse.priceIntervals.map { it.toMutableList() } @@ -725,6 +781,7 @@ private constructor( startDate = subscriptionTriggerPhaseResponse.startDate status = subscriptionTriggerPhaseResponse.status trialInfo = subscriptionTriggerPhaseResponse.trialInfo + changedResources = subscriptionTriggerPhaseResponse.changedResources additionalProperties = subscriptionTriggerPhaseResponse.additionalProperties.toMutableMap() } @@ -1170,6 +1227,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1263,6 +1343,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1308,6 +1411,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1341,12 +1445,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1377,12 +1483,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1420,12 +1528,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8512,6 +8622,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10096,20 +10363,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionTriggerPhaseResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionTriggerPhaseResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionTriggerPhaseResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionTriggerPhaseResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt index 98187f8d..3594ee80 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -727,6 +781,8 @@ private constructor( it.toMutableList() } netTerms = subscriptionUnscheduleCancellationResponse.netTerms + pendingSubscriptionChange = + subscriptionUnscheduleCancellationResponse.pendingSubscriptionChange plan = subscriptionUnscheduleCancellationResponse.plan priceIntervals = subscriptionUnscheduleCancellationResponse.priceIntervals.map { it.toMutableList() } @@ -734,6 +790,7 @@ private constructor( startDate = subscriptionUnscheduleCancellationResponse.startDate status = subscriptionUnscheduleCancellationResponse.status trialInfo = subscriptionUnscheduleCancellationResponse.trialInfo + changedResources = subscriptionUnscheduleCancellationResponse.changedResources additionalProperties = subscriptionUnscheduleCancellationResponse.additionalProperties.toMutableMap() } @@ -1179,6 +1236,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1272,6 +1352,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1317,6 +1420,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1350,12 +1454,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1386,12 +1492,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1429,12 +1537,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8521,6 +8631,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10105,20 +10372,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionUnscheduleCancellationResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionUnscheduleCancellationResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionUnscheduleCancellationResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionUnscheduleCancellationResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt index f99b05e3..d9f8a26e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -732,6 +786,8 @@ private constructor( it.toMutableList() } netTerms = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms + pendingSubscriptionChange = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.pendingSubscriptionChange plan = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan priceIntervals = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals.map { @@ -741,6 +797,8 @@ private constructor( startDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.startDate status = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.status trialInfo = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.trialInfo + changedResources = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.changedResources additionalProperties = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.additionalProperties .toMutableMap() @@ -1187,6 +1245,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1280,6 +1361,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1325,6 +1429,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1358,12 +1463,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1394,12 +1501,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1437,12 +1546,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8529,6 +8640,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10113,20 +10381,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt index 6fc5b60a..cd3acd27 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -729,6 +783,8 @@ private constructor( it.toMutableList() } netTerms = subscriptionUnschedulePendingPlanChangesResponse.netTerms + pendingSubscriptionChange = + subscriptionUnschedulePendingPlanChangesResponse.pendingSubscriptionChange plan = subscriptionUnschedulePendingPlanChangesResponse.plan priceIntervals = subscriptionUnschedulePendingPlanChangesResponse.priceIntervals.map { @@ -738,6 +794,7 @@ private constructor( startDate = subscriptionUnschedulePendingPlanChangesResponse.startDate status = subscriptionUnschedulePendingPlanChangesResponse.status trialInfo = subscriptionUnschedulePendingPlanChangesResponse.trialInfo + changedResources = subscriptionUnschedulePendingPlanChangesResponse.changedResources additionalProperties = subscriptionUnschedulePendingPlanChangesResponse.additionalProperties.toMutableMap() } @@ -1183,6 +1240,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1276,6 +1356,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1321,6 +1424,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1354,12 +1458,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1390,12 +1496,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1433,12 +1541,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8525,6 +8635,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10109,20 +10376,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionUnschedulePendingPlanChangesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionUnschedulePendingPlanChangesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionUnschedulePendingPlanChangesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionUnschedulePendingPlanChangesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt index f308cc4d..d39d6856 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -727,6 +781,8 @@ private constructor( it.toMutableList() } netTerms = subscriptionUpdateFixedFeeQuantityResponse.netTerms + pendingSubscriptionChange = + subscriptionUpdateFixedFeeQuantityResponse.pendingSubscriptionChange plan = subscriptionUpdateFixedFeeQuantityResponse.plan priceIntervals = subscriptionUpdateFixedFeeQuantityResponse.priceIntervals.map { it.toMutableList() } @@ -734,6 +790,7 @@ private constructor( startDate = subscriptionUpdateFixedFeeQuantityResponse.startDate status = subscriptionUpdateFixedFeeQuantityResponse.status trialInfo = subscriptionUpdateFixedFeeQuantityResponse.trialInfo + changedResources = subscriptionUpdateFixedFeeQuantityResponse.changedResources additionalProperties = subscriptionUpdateFixedFeeQuantityResponse.additionalProperties.toMutableMap() } @@ -1179,6 +1236,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1272,6 +1352,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1317,6 +1420,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1350,12 +1454,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1386,12 +1492,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1429,12 +1537,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8521,6 +8631,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10105,20 +10372,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionUpdateFixedFeeQuantityResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionUpdateFixedFeeQuantityResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionUpdateFixedFeeQuantityResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionUpdateFixedFeeQuantityResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt index a13f8048..92ee0f7f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt @@ -52,12 +52,14 @@ private constructor( private val metadata: JsonField, private val minimumIntervals: JsonField>, private val netTerms: JsonField, + private val pendingSubscriptionChange: JsonField, private val plan: JsonField, private val priceIntervals: JsonField>, private val redeemedCoupon: JsonField, private val startDate: JsonField, private val status: JsonField, private val trialInfo: JsonField, + private val changedResources: JsonField, private val additionalProperties: MutableMap, ) { @@ -113,6 +115,9 @@ private constructor( @ExcludeMissing minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), + @JsonProperty("pending_subscription_change") + @ExcludeMissing + pendingSubscriptionChange: JsonField = JsonMissing.of(), @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing @@ -127,6 +132,9 @@ private constructor( @JsonProperty("trial_info") @ExcludeMissing trialInfo: JsonField = JsonMissing.of(), + @JsonProperty("changed_resources") + @ExcludeMissing + changedResources: JsonField = JsonMissing.of(), ) : this( id, activePlanPhaseOrder, @@ -147,12 +155,14 @@ private constructor( metadata, minimumIntervals, netTerms, + pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, + changedResources, mutableMapOf(), ) @@ -338,6 +348,15 @@ private constructor( */ fun netTerms(): Long = netTerms.getRequired("net_terms") + /** + * A pending subscription change if one exists on this subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pendingSubscriptionChange(): Optional = + pendingSubscriptionChange.getOptional("pending_subscription_change") + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed * to by a customer. Plans define the billing behavior of the subscription. You can see more @@ -382,6 +401,17 @@ private constructor( */ fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun changedResources(): Optional = + changedResources.getOptional("changed_resources") + /** * Returns the raw JSON value of [id]. * @@ -556,6 +586,17 @@ private constructor( */ @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + /** + * Returns the raw JSON value of [pendingSubscriptionChange]. + * + * Unlike [pendingSubscriptionChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pending_subscription_change") + @ExcludeMissing + fun _pendingSubscriptionChange(): JsonField = + pendingSubscriptionChange + /** * Returns the raw JSON value of [plan]. * @@ -604,6 +645,16 @@ private constructor( */ @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + /** + * Returns the raw JSON value of [changedResources]. + * + * Unlike [changedResources], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("changed_resources") + @ExcludeMissing + fun _changedResources(): JsonField = changedResources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -643,6 +694,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -678,12 +730,14 @@ private constructor( private var metadata: JsonField? = null private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null + private var pendingSubscriptionChange: JsonField? = null private var plan: JsonField? = null private var priceIntervals: JsonField>? = null private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null private var trialInfo: JsonField? = null + private var changedResources: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -718,6 +772,8 @@ private constructor( minimumIntervals = subscriptionUpdateTrialResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionUpdateTrialResponse.netTerms + pendingSubscriptionChange = + subscriptionUpdateTrialResponse.pendingSubscriptionChange plan = subscriptionUpdateTrialResponse.plan priceIntervals = subscriptionUpdateTrialResponse.priceIntervals.map { it.toMutableList() } @@ -725,6 +781,7 @@ private constructor( startDate = subscriptionUpdateTrialResponse.startDate status = subscriptionUpdateTrialResponse.status trialInfo = subscriptionUpdateTrialResponse.trialInfo + changedResources = subscriptionUpdateTrialResponse.changedResources additionalProperties = subscriptionUpdateTrialResponse.additionalProperties.toMutableMap() } @@ -1170,6 +1227,29 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** A pending subscription change if one exists on this subscription. */ + fun pendingSubscriptionChange(pendingSubscriptionChange: PendingSubscriptionChange?) = + pendingSubscriptionChange(JsonField.ofNullable(pendingSubscriptionChange)) + + /** + * Alias for calling [Builder.pendingSubscriptionChange] with + * `pendingSubscriptionChange.orElse(null)`. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: Optional + ) = pendingSubscriptionChange(pendingSubscriptionChange.getOrNull()) + + /** + * Sets [Builder.pendingSubscriptionChange] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingSubscriptionChange] with a well-typed + * [PendingSubscriptionChange] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun pendingSubscriptionChange( + pendingSubscriptionChange: JsonField + ) = apply { this.pendingSubscriptionChange = pendingSubscriptionChange } + /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You @@ -1263,6 +1343,29 @@ private constructor( */ fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + /** + * The resources that were changed as part of this operation. Only present when fetched + * through the subscription changes API or if the `include_changed_resources` parameter was + * passed in the request. + */ + fun changedResources(changedResources: ChangedResources?) = + changedResources(JsonField.ofNullable(changedResources)) + + /** Alias for calling [Builder.changedResources] with `changedResources.orElse(null)`. */ + fun changedResources(changedResources: Optional) = + changedResources(changedResources.getOrNull()) + + /** + * Sets [Builder.changedResources] to an arbitrary JSON value. + * + * You should usually call [Builder.changedResources] with a well-typed [ChangedResources] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun changedResources(changedResources: JsonField) = apply { + this.changedResources = changedResources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1308,6 +1411,7 @@ private constructor( * .metadata() * .minimumIntervals() * .netTerms() + * .pendingSubscriptionChange() * .plan() * .priceIntervals() * .redeemedCoupon() @@ -1341,12 +1445,14 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, checkRequired("netTerms", netTerms), + checkRequired("pendingSubscriptionChange", pendingSubscriptionChange), checkRequired("plan", plan), checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, checkRequired("redeemedCoupon", redeemedCoupon), checkRequired("startDate", startDate), checkRequired("status", status), checkRequired("trialInfo", trialInfo), + changedResources, additionalProperties.toMutableMap(), ) } @@ -1377,12 +1483,14 @@ private constructor( metadata().validate() minimumIntervals().forEach { it.validate() } netTerms() + pendingSubscriptionChange().ifPresent { it.validate() } plan().validate() priceIntervals().forEach { it.validate() } redeemedCoupon().ifPresent { it.validate() } startDate() status().validate() trialInfo().validate() + changedResources().ifPresent { it.validate() } validated = true } @@ -1420,12 +1528,14 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimumIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (pendingSubscriptionChange.asKnown().getOrNull()?.validity() ?: 0) + (plan.asKnown().getOrNull()?.validity() ?: 0) + (priceIntervals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (redeemedCoupon.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + (trialInfo.asKnown().getOrNull()?.validity() ?: 0) + + (changedResources.asKnown().getOrNull()?.validity() ?: 0) class AdjustmentInterval private constructor( @@ -8512,6 +8622,163 @@ private constructor( "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" } + /** A pending subscription change if one exists on this subscription. */ + class PendingSubscriptionChange + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PendingSubscriptionChange]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PendingSubscriptionChange]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pendingSubscriptionChange: PendingSubscriptionChange) = apply { + id = pendingSubscriptionChange.id + additionalProperties = pendingSubscriptionChange.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 [PendingSubscriptionChange]. + * + * 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(): PendingSubscriptionChange = + PendingSubscriptionChange( + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PendingSubscriptionChange = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PendingSubscriptionChange && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PendingSubscriptionChange{id=$id, additionalProperties=$additionalProperties}" + } + /** * The Price Interval resource represents a period of time for which a price will bill on a * subscription. A subscription’s price intervals define its billing behavior. @@ -10096,20 +10363,383 @@ private constructor( "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" } + /** + * The resources that were changed as part of this operation. Only present when fetched through + * the subscription changes API or if the `include_changed_resources` parameter was passed in + * the request. + */ + class ChangedResources + private constructor( + private val createdCreditNotes: JsonField>, + private val createdInvoices: JsonField>, + private val voidedCreditNotes: JsonField>, + private val voidedInvoices: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("created_credit_notes") + @ExcludeMissing + createdCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("created_invoices") + @ExcludeMissing + createdInvoices: JsonField> = JsonMissing.of(), + @JsonProperty("voided_credit_notes") + @ExcludeMissing + voidedCreditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("voided_invoices") + @ExcludeMissing + voidedInvoices: JsonField> = JsonMissing.of(), + ) : this( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + mutableMapOf(), + ) + + /** + * The credit notes that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdCreditNotes(): List = + createdCreditNotes.getRequired("created_credit_notes") + + /** + * The invoices that were created as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") + + /** + * The credit notes that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedCreditNotes(): List = + voidedCreditNotes.getRequired("voided_credit_notes") + + /** + * The invoices that were voided as part of this operation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun voidedInvoices(): List = voidedInvoices.getRequired("voided_invoices") + + /** + * Returns the raw JSON value of [createdCreditNotes]. + * + * Unlike [createdCreditNotes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("created_credit_notes") + @ExcludeMissing + fun _createdCreditNotes(): JsonField> = createdCreditNotes + + /** + * Returns the raw JSON value of [createdInvoices]. + * + * Unlike [createdInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_invoices") + @ExcludeMissing + fun _createdInvoices(): JsonField> = createdInvoices + + /** + * Returns the raw JSON value of [voidedCreditNotes]. + * + * Unlike [voidedCreditNotes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_credit_notes") + @ExcludeMissing + fun _voidedCreditNotes(): JsonField> = voidedCreditNotes + + /** + * Returns the raw JSON value of [voidedInvoices]. + * + * Unlike [voidedInvoices], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("voided_invoices") + @ExcludeMissing + fun _voidedInvoices(): JsonField> = voidedInvoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangedResources]. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangedResources]. */ + class Builder internal constructor() { + + private var createdCreditNotes: JsonField>? = null + private var createdInvoices: JsonField>? = null + private var voidedCreditNotes: JsonField>? = null + private var voidedInvoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changedResources: ChangedResources) = apply { + createdCreditNotes = changedResources.createdCreditNotes.map { it.toMutableList() } + createdInvoices = changedResources.createdInvoices.map { it.toMutableList() } + voidedCreditNotes = changedResources.voidedCreditNotes.map { it.toMutableList() } + voidedInvoices = changedResources.voidedInvoices.map { it.toMutableList() } + additionalProperties = changedResources.additionalProperties.toMutableMap() + } + + /** The credit notes that were created as part of this operation. */ + fun createdCreditNotes(createdCreditNotes: List) = + createdCreditNotes(JsonField.of(createdCreditNotes)) + + /** + * Sets [Builder.createdCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.createdCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun createdCreditNotes(createdCreditNotes: JsonField>) = apply { + this.createdCreditNotes = createdCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [createdCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedCreditNote(createdCreditNote: CreditNote) = apply { + createdCreditNotes = + (createdCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("createdCreditNotes", it).add(createdCreditNote) + } + } + + /** The invoices that were created as part of this operation. */ + fun createdInvoices(createdInvoices: List) = + createdInvoices(JsonField.of(createdInvoices)) + + /** + * Sets [Builder.createdInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.createdInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun createdInvoices(createdInvoices: JsonField>) = apply { + this.createdInvoices = createdInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [createdInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreatedInvoice(createdInvoice: Invoice) = apply { + createdInvoices = + (createdInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("createdInvoices", it).add(createdInvoice) + } + } + + /** The credit notes that were voided as part of this operation. */ + fun voidedCreditNotes(voidedCreditNotes: List) = + voidedCreditNotes(JsonField.of(voidedCreditNotes)) + + /** + * Sets [Builder.voidedCreditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedCreditNotes] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun voidedCreditNotes(voidedCreditNotes: JsonField>) = apply { + this.voidedCreditNotes = voidedCreditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [voidedCreditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedCreditNote(voidedCreditNote: CreditNote) = apply { + voidedCreditNotes = + (voidedCreditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedCreditNotes", it).add(voidedCreditNote) + } + } + + /** The invoices that were voided as part of this operation. */ + fun voidedInvoices(voidedInvoices: List) = + voidedInvoices(JsonField.of(voidedInvoices)) + + /** + * Sets [Builder.voidedInvoices] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedInvoices] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun voidedInvoices(voidedInvoices: JsonField>) = apply { + this.voidedInvoices = voidedInvoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [voidedInvoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVoidedInvoice(voidedInvoice: Invoice) = apply { + voidedInvoices = + (voidedInvoices ?: JsonField.of(mutableListOf())).also { + checkKnown("voidedInvoices", it).add(voidedInvoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangedResources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .createdCreditNotes() + * .createdInvoices() + * .voidedCreditNotes() + * .voidedInvoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChangedResources = + ChangedResources( + checkRequired("createdCreditNotes", createdCreditNotes).map { + it.toImmutable() + }, + checkRequired("createdInvoices", createdInvoices).map { it.toImmutable() }, + checkRequired("voidedCreditNotes", voidedCreditNotes).map { it.toImmutable() }, + checkRequired("voidedInvoices", voidedInvoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChangedResources = apply { + if (validated) { + return@apply + } + + createdCreditNotes().forEach { it.validate() } + createdInvoices().forEach { it.validate() } + voidedCreditNotes().forEach { it.validate() } + voidedInvoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (createdCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (createdInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChangedResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangedResources{createdCreditNotes=$createdCreditNotes, createdInvoices=$createdInvoices, voidedCreditNotes=$voidedCreditNotes, voidedInvoices=$voidedInvoices, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionUpdateTrialResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SubscriptionUpdateTrialResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && pendingSubscriptionChange == other.pendingSubscriptionChange && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && changedResources == other.changedResources && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, pendingSubscriptionChange, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, changedResources, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SubscriptionUpdateTrialResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" + "SubscriptionUpdateTrialResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, pendingSubscriptionChange=$pendingSubscriptionChange, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, changedResources=$changedResources, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt new file mode 100644 index 00000000..99380e5b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeApplyResponse +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeCancelResponse +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import com.withorb.api.models.SubscriptionChangeRetrieveResponse +import java.util.concurrent.CompletableFuture + +interface SubscriptionChangeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * This endpoint returns a subscription change given an identifier. + * + * A subscription change is created by including `Create-Pending-Subscription-Change: True` in + * the header of a subscription mutation API call (e.g. + * [create subscription endpoint](/api-reference/subscription/create-subscription), [schedule + * plan change endpoint](/api-reference/subscription/schedule-plan-change), ...). The + * subscription change will be referenced by the `pending_subscription_change` field in the + * response. + */ + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Apply a subscription change to perform the intended action. If a positive amount is passed + * with a request to this endpoint, any eligible invoices that were created will be issued + * immediately if they only contain in-advance fees. + */ + fun apply( + params: SubscriptionChangeApplyParams + ): CompletableFuture = apply(params, RequestOptions.none()) + + /** @see [apply] */ + fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Cancel a subscription change. The change can no longer be applied. A subscription can only + * have one "pending" change at a time - use this endpoint to cancel an existing change before + * creating a new one. + */ + fun cancel( + params: SubscriptionChangeCancelParams + ): CompletableFuture = cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [SubscriptionChangeServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /subscription_changes/{subscription_change_id}`, but + * is otherwise the same as [SubscriptionChangeServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscription_changes/{subscription_change_id}/apply`, but is otherwise the same as + * [SubscriptionChangeServiceAsync.apply]. + */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams + ): CompletableFuture> = + apply(params, RequestOptions.none()) + + /** @see [apply] */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscription_changes/{subscription_change_id}/cancel`, but is otherwise the same as + * [SubscriptionChangeServiceAsync.cancel]. + */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt new file mode 100644 index 00000000..dfa31c96 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.JsonValue +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.handlers.withErrorHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeApplyResponse +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeCancelResponse +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import com.withorb.api.models.SubscriptionChangeRetrieveResponse +import java.util.concurrent.CompletableFuture + +class SubscriptionChangeServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : SubscriptionChangeServiceAsync { + + private val withRawResponse: SubscriptionChangeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SubscriptionChangeServiceAsync.WithRawResponse = withRawResponse + + override fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /subscription_changes/{subscription_change_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /subscription_changes/{subscription_change_id}/apply + withRawResponse().apply(params, requestOptions).thenApply { it.parse() } + + override fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /subscription_changes/{subscription_change_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionChangeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscription_changes", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val applyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscription_changes", params._pathParam(0), "apply") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { applyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscription_changes", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt new file mode 100644 index 00000000..13946e44 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeApplyResponse +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeCancelResponse +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import com.withorb.api.models.SubscriptionChangeRetrieveResponse + +interface SubscriptionChangeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * This endpoint returns a subscription change given an identifier. + * + * A subscription change is created by including `Create-Pending-Subscription-Change: True` in + * the header of a subscription mutation API call (e.g. + * [create subscription endpoint](/api-reference/subscription/create-subscription), [schedule + * plan change endpoint](/api-reference/subscription/schedule-plan-change), ...). The + * subscription change will be referenced by the `pending_subscription_change` field in the + * response. + */ + fun retrieve(params: SubscriptionChangeRetrieveParams): SubscriptionChangeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeRetrieveResponse + + /** + * Apply a subscription change to perform the intended action. If a positive amount is passed + * with a request to this endpoint, any eligible invoices that were created will be issued + * immediately if they only contain in-advance fees. + */ + fun apply(params: SubscriptionChangeApplyParams): SubscriptionChangeApplyResponse = + apply(params, RequestOptions.none()) + + /** @see [apply] */ + fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeApplyResponse + + /** + * Cancel a subscription change. The change can no longer be applied. A subscription can only + * have one "pending" change at a time - use this endpoint to cancel an existing change before + * creating a new one. + */ + fun cancel(params: SubscriptionChangeCancelParams): SubscriptionChangeCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeCancelResponse + + /** + * A view of [SubscriptionChangeService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /subscription_changes/{subscription_change_id}`, but + * is otherwise the same as [SubscriptionChangeService.retrieve]. + */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscription_changes/{subscription_change_id}/apply`, but is otherwise the same as + * [SubscriptionChangeService.apply]. + */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams + ): HttpResponseFor = apply(params, RequestOptions.none()) + + /** @see [apply] */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscription_changes/{subscription_change_id}/cancel`, but is otherwise the same as + * [SubscriptionChangeService.cancel]. + */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams + ): HttpResponseFor = cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt new file mode 100644 index 00000000..87fd8858 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.JsonValue +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.handlers.withErrorHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeApplyResponse +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeCancelResponse +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import com.withorb.api.models.SubscriptionChangeRetrieveResponse + +class SubscriptionChangeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionChangeService { + + private val withRawResponse: SubscriptionChangeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SubscriptionChangeService.WithRawResponse = withRawResponse + + override fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions, + ): SubscriptionChangeRetrieveResponse = + // get /subscription_changes/{subscription_change_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions, + ): SubscriptionChangeApplyResponse = + // post /subscription_changes/{subscription_change_id}/apply + withRawResponse().apply(params, requestOptions).parse() + + override fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions, + ): SubscriptionChangeCancelResponse = + // post /subscription_changes/{subscription_change_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionChangeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: SubscriptionChangeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscription_changes", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val applyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun apply( + params: SubscriptionChangeApplyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscription_changes", params._pathParam(0), "apply") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { applyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun cancel( + params: SubscriptionChangeCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscription_changes", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt index 3aa43326..1bf45e53 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt @@ -190,6 +190,9 @@ internal class SubscriptionCancelResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionCancelResponse.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -503,6 +506,900 @@ internal class SubscriptionCancelResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionCancelResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionCancelResponse.id()).isEqualTo("id") @@ -693,6 +1590,10 @@ internal class SubscriptionCancelResponseTest { .build() ) assertThat(subscriptionCancelResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionCancelResponse.pendingSubscriptionChange()) + .contains( + SubscriptionCancelResponse.PendingSubscriptionChange.builder().id("id").build() + ) assertThat(subscriptionCancelResponse.plan()) .isEqualTo( Plan.builder() @@ -1004,73 +1905,930 @@ internal class SubscriptionCancelResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionCancelResponse = - SubscriptionCancelResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionCancelResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) + assertThat(subscriptionCancelResponse.changedResources()) + .contains( + SubscriptionCancelResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionCancelResponse = + SubscriptionCancelResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionCancelResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( @@ -1186,6 +2944,9 @@ internal class SubscriptionCancelResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionCancelResponse.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -1499,6 +3260,900 @@ internal class SubscriptionCancelResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionCancelResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionCancelResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt new file mode 100644 index 00000000..0b572915 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeApplyParamsTest { + + @Test + fun create() { + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .description("description") + .previouslyCollectedAmount("previously_collected_amount") + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("subscription_change_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .description("description") + .previouslyCollectedAmount("previously_collected_amount") + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.previouslyCollectedAmount()).contains("previously_collected_amount") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + + val body = params._body() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt new file mode 100644 index 00000000..28d0ad07 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -0,0 +1,4673 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeApplyResponseTest { + + @Test + fun create() { + val subscriptionChangeApplyResponse = + SubscriptionChangeApplyResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeApplyResponse.Status.PENDING) + .subscription( + SubscriptionChangeApplyResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeApplyResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeApplyResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeApplyResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeApplyResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeApplyResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeApplyResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeApplyResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeApplyResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeApplyResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeApplyResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeApplyResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeApplyResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeApplyResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(subscriptionChangeApplyResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeApplyResponse.expirationTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeApplyResponse.status()) + .isEqualTo(SubscriptionChangeApplyResponse.Status.PENDING) + assertThat(subscriptionChangeApplyResponse.subscription()) + .contains( + SubscriptionChangeApplyResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeApplyResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeApplyResponse.Subscription.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeApplyResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeApplyResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeApplyResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeApplyResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeApplyResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeApplyResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeApplyResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeApplyResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeApplyResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeApplyResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeApplyResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + assertThat(subscriptionChangeApplyResponse.appliedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeApplyResponse.cancelledAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionChangeApplyResponse = + SubscriptionChangeApplyResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeApplyResponse.Status.PENDING) + .subscription( + SubscriptionChangeApplyResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeApplyResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeApplyResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeApplyResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeApplyResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeApplyResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeApplyResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeApplyResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeApplyResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeApplyResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeApplyResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeApplyResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeApplyResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeApplyResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeApplyResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSubscriptionChangeApplyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionChangeApplyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionChangeApplyResponse) + .isEqualTo(subscriptionChangeApplyResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelParamsTest.kt new file mode 100644 index 00000000..61765722 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeCancelParamsTest { + + @Test + fun create() { + SubscriptionChangeCancelParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionChangeCancelParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("subscription_change_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt new file mode 100644 index 00000000..d140d9eb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -0,0 +1,4674 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeCancelResponseTest { + + @Test + fun create() { + val subscriptionChangeCancelResponse = + SubscriptionChangeCancelResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeCancelResponse.Status.PENDING) + .subscription( + SubscriptionChangeCancelResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeCancelResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeCancelResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeCancelResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeCancelResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeCancelResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeCancelResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeCancelResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeCancelResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeCancelResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeCancelResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeCancelResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeCancelResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeCancelResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(subscriptionChangeCancelResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeCancelResponse.expirationTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeCancelResponse.status()) + .isEqualTo(SubscriptionChangeCancelResponse.Status.PENDING) + assertThat(subscriptionChangeCancelResponse.subscription()) + .contains( + SubscriptionChangeCancelResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeCancelResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeCancelResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeCancelResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeCancelResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeCancelResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeCancelResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeCancelResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeCancelResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeCancelResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeCancelResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeCancelResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeCancelResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeCancelResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + assertThat(subscriptionChangeCancelResponse.appliedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeCancelResponse.cancelledAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionChangeCancelResponse = + SubscriptionChangeCancelResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeCancelResponse.Status.PENDING) + .subscription( + SubscriptionChangeCancelResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeCancelResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeCancelResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeCancelResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeCancelResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeCancelResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeCancelResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeCancelResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeCancelResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeCancelResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeCancelResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeCancelResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeCancelResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeCancelResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeCancelResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSubscriptionChangeCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionChangeCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionChangeCancelResponse) + .isEqualTo(subscriptionChangeCancelResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParamsTest.kt new file mode 100644 index 00000000..fbb63152 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeRetrieveParamsTest { + + @Test + fun create() { + SubscriptionChangeRetrieveParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionChangeRetrieveParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("subscription_change_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt new file mode 100644 index 00000000..c3209a16 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -0,0 +1,4684 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionChangeRetrieveResponseTest { + + @Test + fun create() { + val subscriptionChangeRetrieveResponse = + SubscriptionChangeRetrieveResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeRetrieveResponse.Status.PENDING) + .subscription( + SubscriptionChangeRetrieveResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeRetrieveResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeRetrieveResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeRetrieveResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeRetrieveResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeRetrieveResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MaximumInterval + .builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeRetrieveResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MinimumInterval + .builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeRetrieveResponse.Subscription + .PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeRetrieveResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeRetrieveResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeRetrieveResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeRetrieveResponse.Subscription.ChangedResources + .builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(subscriptionChangeRetrieveResponse.id()).isEqualTo("id") + assertThat(subscriptionChangeRetrieveResponse.expirationTime()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeRetrieveResponse.status()) + .isEqualTo(SubscriptionChangeRetrieveResponse.Status.PENDING) + assertThat(subscriptionChangeRetrieveResponse.subscription()) + .contains( + SubscriptionChangeRetrieveResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeRetrieveResponse.Subscription.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionChangeRetrieveResponse.Subscription.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeRetrieveResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeRetrieveResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeRetrieveResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MaximumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeRetrieveResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MinimumInterval.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeRetrieveResponse.Subscription.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeRetrieveResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeRetrieveResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeRetrieveResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeRetrieveResponse.Subscription.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + assertThat(subscriptionChangeRetrieveResponse.appliedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionChangeRetrieveResponse.cancelledAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionChangeRetrieveResponse = + SubscriptionChangeRetrieveResponse.builder() + .id("id") + .expirationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeRetrieveResponse.Status.PENDING) + .subscription( + SubscriptionChangeRetrieveResponse.Subscription.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionChangeRetrieveResponse.Subscription.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionChangeRetrieveResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionChangeRetrieveResponse.Subscription + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionChangeRetrieveResponse.Subscription + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + Customer.Hierarchy.builder() + .addChild( + Customer.Hierarchy.Child.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + Customer.Hierarchy.Parent.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + Customer.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + Customer.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + Customer.TaxId.builder() + .country(Customer.TaxId.Country.AD) + .type(Customer.TaxId.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + Customer.AccountingSyncConfiguration.builder() + .addAccountingProvider( + Customer.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + Customer.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + Customer.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType( + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + SubscriptionChangeRetrieveResponse.Subscription.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MaximumInterval + .builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionChangeRetrieveResponse.Subscription.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + SubscriptionChangeRetrieveResponse.Subscription.MinimumInterval + .builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionChangeRetrieveResponse.Subscription + .PendingSubscriptionChange + .builder() + .id("id") + .build() + ) + .plan( + Plan.builder() + .id("id") + .addAdjustment( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + Plan.BasePlan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Plan.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Plan.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + Plan.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(Plan.Status.ACTIVE) + .trialConfig( + Plan.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + SubscriptionChangeRetrieveResponse.Subscription.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + SubscriptionChangeRetrieveResponse.Subscription.RedeemedCoupon.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionChangeRetrieveResponse.Subscription.Status.ACTIVE) + .trialInfo( + SubscriptionChangeRetrieveResponse.Subscription.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .changedResources( + SubscriptionChangeRetrieveResponse.Subscription.ChangedResources + .builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount + .DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment + .AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse( + "2022-05-01T07:01:31+00:00" + ) + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote + .builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type( + Invoice.CustomerBalanceTransaction.Type + .INCREMENT + ) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate( + OffsetDateTime.parse("2022-05-01T07:00:00+00:00") + ) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice + .BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse( + "2019-12-27T18:11:19.117Z" + ) + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation + .builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId( + "h74gfhdjvn7ujokd" + ) + .addAppliesToPriceId( + "7hfgtgjnbvc3ujkl" + ) + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice + .InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType( + Price.UnitPrice.PriceType.USAGE_PRICE + ) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice + .DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse( + "2022-02-01T08:00:00+00:00" + ) + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem + .MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .paymentStartedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .scheduledIssueAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder() + .id("VDGsT23osdLb84KD") + .build() + ) + .subtotal("8.00") + .syncFailedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + .build() + ) + .appliedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .cancelledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSubscriptionChangeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionChangeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionChangeRetrieveResponse) + .isEqualTo(subscriptionChangeRetrieveResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index d66f5cbe..bcbca74b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -41,7 +41,7 @@ internal class SubscriptionCreateParamsTest { SubscriptionCreateParams.AddPrice.AllocationPrice.builder() .amount("10.00") .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence.ONE_TIME + SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence.MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -203,7 +203,7 @@ internal class SubscriptionCreateParamsTest { .amount("10.00") .cadence( SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -333,7 +333,7 @@ internal class SubscriptionCreateParamsTest { .amount("10.00") .cadence( SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -498,7 +498,7 @@ internal class SubscriptionCreateParamsTest { .amount("10.00") .cadence( SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -632,7 +632,7 @@ internal class SubscriptionCreateParamsTest { SubscriptionCreateParams.AddPrice.AllocationPrice.builder() .amount("10.00") .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence.ONE_TIME + SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence.MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -803,7 +803,7 @@ internal class SubscriptionCreateParamsTest { .amount("10.00") .cadence( SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt index 18c18c41..ecec5b7f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt @@ -190,6 +190,9 @@ internal class SubscriptionCreateResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionCreateResponse.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -503,6 +506,900 @@ internal class SubscriptionCreateResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionCreateResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionCreateResponse.id()).isEqualTo("id") @@ -693,6 +1590,10 @@ internal class SubscriptionCreateResponseTest { .build() ) assertThat(subscriptionCreateResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionCreateResponse.pendingSubscriptionChange()) + .contains( + SubscriptionCreateResponse.PendingSubscriptionChange.builder().id("id").build() + ) assertThat(subscriptionCreateResponse.plan()) .isEqualTo( Plan.builder() @@ -1004,73 +1905,930 @@ internal class SubscriptionCreateResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionCreateResponse = - SubscriptionCreateResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionCreateResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) + assertThat(subscriptionCreateResponse.changedResources()) + .contains( + SubscriptionCreateResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionCreateResponse = + SubscriptionCreateResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionCreateResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( @@ -1186,6 +2944,9 @@ internal class SubscriptionCreateResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionCreateResponse.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -1499,6 +3260,900 @@ internal class SubscriptionCreateResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionCreateResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionCreateResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 15463de5..15c247f2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -21,8 +21,7 @@ internal class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() .amount("10.00") .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME + SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence.MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -181,7 +180,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .amount("10.00") .cadence( SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -329,8 +328,7 @@ internal class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() .amount("10.00") .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME + SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence.MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt index b0fbfbd6..8218d0f0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt @@ -192,6 +192,11 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionPriceIntervalsResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -506,6 +511,900 @@ internal class SubscriptionPriceIntervalsResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionPriceIntervalsResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionPriceIntervalsResponse.id()).isEqualTo("id") @@ -700,6 +1599,12 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) assertThat(subscriptionPriceIntervalsResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionPriceIntervalsResponse.pendingSubscriptionChange()) + .contains( + SubscriptionPriceIntervalsResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionPriceIntervalsResponse.plan()) .isEqualTo( Plan.builder() @@ -1011,69 +1916,926 @@ internal class SubscriptionPriceIntervalsResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionPriceIntervalsResponse = - SubscriptionPriceIntervalsResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionPriceIntervalsResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) + assertThat(subscriptionPriceIntervalsResponse.changedResources()) + .contains( + SubscriptionPriceIntervalsResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionPriceIntervalsResponse = + SubscriptionPriceIntervalsResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionPriceIntervalsResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .email("email") @@ -1195,6 +2957,11 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionPriceIntervalsResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1509,6 +3276,900 @@ internal class SubscriptionPriceIntervalsResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionPriceIntervalsResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionPriceIntervalsResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 77e95a0a..26015afe 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -46,7 +46,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .cadence( SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -211,7 +211,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .cadence( SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -365,7 +365,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .cadence( SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -535,7 +535,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.ReplacePrice .AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -675,7 +675,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .cadence( SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -845,7 +845,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .cadence( SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt index 8782ad26..f148f1a6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt @@ -193,6 +193,11 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionSchedulePlanChangeResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -507,6 +512,900 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionSchedulePlanChangeResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionSchedulePlanChangeResponse.id()).isEqualTo("id") @@ -701,6 +1600,12 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) assertThat(subscriptionSchedulePlanChangeResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionSchedulePlanChangeResponse.pendingSubscriptionChange()) + .contains( + SubscriptionSchedulePlanChangeResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionSchedulePlanChangeResponse.plan()) .isEqualTo( Plan.builder() @@ -1013,69 +1918,926 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionSchedulePlanChangeResponse = - SubscriptionSchedulePlanChangeResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() + assertThat(subscriptionSchedulePlanChangeResponse.changedResources()) + .contains( + SubscriptionSchedulePlanChangeResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionSchedulePlanChangeResponse = + SubscriptionSchedulePlanChangeResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionSchedulePlanChangeResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") @@ -1198,6 +2960,11 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionSchedulePlanChangeResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1512,6 +3279,900 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionSchedulePlanChangeResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionSchedulePlanChangeResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index e457c341..e286f522 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -188,6 +188,9 @@ internal class SubscriptionTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + Subscription.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -687,6 +690,8 @@ internal class SubscriptionTest { .build() ) assertThat(subscription.netTerms()).isEqualTo(0L) + assertThat(subscription.pendingSubscriptionChange()) + .contains(Subscription.PendingSubscriptionChange.builder().id("id").build()) assertThat(subscription.plan()) .isEqualTo( Plan.builder() @@ -1176,6 +1181,9 @@ internal class SubscriptionTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + Subscription.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt index ae7fab59..6dcd43e4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt @@ -191,6 +191,11 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionTriggerPhaseResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -505,6 +510,900 @@ internal class SubscriptionTriggerPhaseResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionTriggerPhaseResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionTriggerPhaseResponse.id()).isEqualTo("id") @@ -698,6 +1597,12 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) assertThat(subscriptionTriggerPhaseResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionTriggerPhaseResponse.pendingSubscriptionChange()) + .contains( + SubscriptionTriggerPhaseResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionTriggerPhaseResponse.plan()) .isEqualTo( Plan.builder() @@ -1009,69 +1914,926 @@ internal class SubscriptionTriggerPhaseResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionTriggerPhaseResponse = - SubscriptionTriggerPhaseResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionTriggerPhaseResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) + assertThat(subscriptionTriggerPhaseResponse.changedResources()) + .contains( + SubscriptionTriggerPhaseResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionTriggerPhaseResponse = + SubscriptionTriggerPhaseResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionTriggerPhaseResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .email("email") @@ -1192,6 +2954,11 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionTriggerPhaseResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1506,6 +3273,900 @@ internal class SubscriptionTriggerPhaseResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionTriggerPhaseResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionTriggerPhaseResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt index 0d02f5ee..2b1a5fdf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt @@ -195,6 +195,11 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnscheduleCancellationResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -509,6 +514,900 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnscheduleCancellationResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionUnscheduleCancellationResponse.id()).isEqualTo("id") @@ -705,6 +1604,12 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) assertThat(subscriptionUnscheduleCancellationResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionUnscheduleCancellationResponse.pendingSubscriptionChange()) + .contains( + SubscriptionUnscheduleCancellationResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionUnscheduleCancellationResponse.plan()) .isEqualTo( Plan.builder() @@ -1017,69 +1922,926 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionUnscheduleCancellationResponse = - SubscriptionUnscheduleCancellationResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnscheduleCancellationResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") + assertThat(subscriptionUnscheduleCancellationResponse.changedResources()) + .contains( + SubscriptionUnscheduleCancellationResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnscheduleCancellationResponse = + SubscriptionUnscheduleCancellationResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnscheduleCancellationResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1204,6 +2966,11 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnscheduleCancellationResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1518,6 +3285,900 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnscheduleCancellationResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionUnscheduleCancellationResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt index 48efd8b3..3133426a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt @@ -200,6 +200,12 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -514,6 +520,900 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.id()).isEqualTo("id") @@ -726,6 +1626,15 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms()).isEqualTo(0L) + assertThat( + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.pendingSubscriptionChange() + ) + .contains( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan()) .isEqualTo( Plan.builder() @@ -1038,65 +1947,922 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval - .builder() - .id("id") - .adjustment( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.changedResources()) + .contains( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") .billingAddress( Customer.BillingAddress.builder() .city("city") @@ -1230,6 +2996,12 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1544,6 +3316,900 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt index f86b193e..e743458f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt @@ -198,6 +198,12 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnschedulePendingPlanChangesResponse.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -512,6 +518,900 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnschedulePendingPlanChangesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionUnschedulePendingPlanChangesResponse.id()).isEqualTo("id") @@ -713,6 +1613,12 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) assertThat(subscriptionUnschedulePendingPlanChangesResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.pendingSubscriptionChange()) + .contains( + SubscriptionUnschedulePendingPlanChangesResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionUnschedulePendingPlanChangesResponse.plan()) .isEqualTo( Plan.builder() @@ -1025,68 +1931,925 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionUnschedulePendingPlanChangesResponse = - SubscriptionUnschedulePendingPlanChangesResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnschedulePendingPlanChangesResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") + assertThat(subscriptionUnschedulePendingPlanChangesResponse.changedResources()) + .contains( + SubscriptionUnschedulePendingPlanChangesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUnschedulePendingPlanChangesResponse = + SubscriptionUnschedulePendingPlanChangesResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUnschedulePendingPlanChangesResponse + .AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUnschedulePendingPlanChangesResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") .line2("line2") .postalCode("postal_code") .state("state") @@ -1215,6 +2978,12 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUnschedulePendingPlanChangesResponse.PendingSubscriptionChange + .builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1529,6 +3298,900 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUnschedulePendingPlanChangesResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionUnschedulePendingPlanChangesResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt index 137ea292..dc0a8f11 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt @@ -195,6 +195,11 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUpdateFixedFeeQuantityResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -509,6 +514,900 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUpdateFixedFeeQuantityResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionUpdateFixedFeeQuantityResponse.id()).isEqualTo("id") @@ -705,6 +1604,12 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) assertThat(subscriptionUpdateFixedFeeQuantityResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.pendingSubscriptionChange()) + .contains( + SubscriptionUpdateFixedFeeQuantityResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) assertThat(subscriptionUpdateFixedFeeQuantityResponse.plan()) .isEqualTo( Plan.builder() @@ -1017,69 +1922,926 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionUpdateFixedFeeQuantityResponse = - SubscriptionUpdateFixedFeeQuantityResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUpdateFixedFeeQuantityResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") + assertThat(subscriptionUpdateFixedFeeQuantityResponse.changedResources()) + .contains( + SubscriptionUpdateFixedFeeQuantityResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUpdateFixedFeeQuantityResponse = + SubscriptionUpdateFixedFeeQuantityResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval + .Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUpdateFixedFeeQuantityResponse.BillingCycleAnchorConfiguration + .builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") .build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1204,6 +2966,11 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUpdateFixedFeeQuantityResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1518,6 +3285,900 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUpdateFixedFeeQuantityResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionUpdateFixedFeeQuantityResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt index 76204150..1794498b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt @@ -191,6 +191,11 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUpdateTrialResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -504,6 +509,900 @@ internal class SubscriptionUpdateTrialResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUpdateTrialResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() assertThat(subscriptionUpdateTrialResponse.id()).isEqualTo("id") @@ -697,6 +1596,10 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) assertThat(subscriptionUpdateTrialResponse.netTerms()).isEqualTo(0L) + assertThat(subscriptionUpdateTrialResponse.pendingSubscriptionChange()) + .contains( + SubscriptionUpdateTrialResponse.PendingSubscriptionChange.builder().id("id").build() + ) assertThat(subscriptionUpdateTrialResponse.plan()) .isEqualTo( Plan.builder() @@ -1008,71 +1911,928 @@ internal class SubscriptionUpdateTrialResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionUpdateTrialResponse = - SubscriptionUpdateTrialResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUpdateTrialResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") + assertThat(subscriptionUpdateTrialResponse.changedResources()) + .contains( + SubscriptionUpdateTrialResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionUpdateTrialResponse = + SubscriptionUpdateTrialResponse.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionUpdateTrialResponse.BillingCycleAnchorConfiguration.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + Customer.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + Customer.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") .email("email") .emailDelivery(true) .exemptFromAutomatedTax(true) @@ -1191,6 +2951,11 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + SubscriptionUpdateTrialResponse.PendingSubscriptionChange.builder() + .id("id") + .build() + ) .plan( Plan.builder() .id("id") @@ -1504,6 +3269,900 @@ internal class SubscriptionUpdateTrialResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) + .changedResources( + SubscriptionUpdateTrialResponse.ChangedResources.builder() + .addCreatedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addCreatedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .addVoidedCreditNote( + CreditNote.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CreditNote.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNote.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + CreditNote.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNote.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNote.LineItem.Discount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNote.MaximumAmountAdjustment.builder() + .amountApplied("amount_applied") + .discountType( + CreditNote.MaximumAmountAdjustment.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.MaximumAmountAdjustment.AppliesToPrice + .builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNote.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNote.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNote.Discount.builder() + .amountApplied("amount_applied") + .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNote.Discount.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + ) + .addVoidedInvoice( + Invoice.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + Invoice.AutoCollection.builder() + .enabled(true) + .nextAttemptAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .numAttempts(0L) + .previouslyAttemptedAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .billingAddress( + Invoice.BillingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + Invoice.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + Invoice.Customer.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + Invoice.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + Invoice.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt( + OffsetDateTime.parse("2022-05-01T07:01:31+00:00") + ) + .creditNote( + Invoice.CustomerBalanceTransaction.CreditNote.builder() + .id("id") + .build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + Invoice.CustomerBalanceTransaction.InnerInvoice + .builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + Invoice.CustomerTaxId.builder() + .country(Invoice.CustomerTaxId.Country.AD) + .type(Invoice.CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf( + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .invoiceSource(Invoice.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + Invoice.LineItem.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + Invoice.LineItem.Adjustment + .MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + Invoice.LineItem.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Invoice.LineItem.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType + .PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration + .builder() + .duration(0L) + .durationUnit( + Price.UnitPrice + .InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + Price.UnitPrice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + Price.UnitPrice.DimensionalPriceConfiguration + .builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .quantity(1.0) + .startDate( + OffsetDateTime.parse("2022-02-01T08:00:00+00:00") + ) + .addSubLineItem( + Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Grouping + .builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + Invoice.LineItem.SubLineItem.MatrixSubLineItem + .Type + .MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + Invoice.LineItem.TaxAmount.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + Invoice.Maximum.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + Invoice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Invoice.Minimum.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + Invoice.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + Invoice.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Invoice.ShippingAddress.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(Invoice.Status.ISSUED) + .subscription( + Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build() + ) + .subtotal("8.00") + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + ) + .build() + ) .build() val roundtrippedSubscriptionUpdateTrialResponse = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 556cfe64..f638ba37 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -197,6 +197,9 @@ internal class SubscriptionsTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + Subscription.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -731,6 +734,9 @@ internal class SubscriptionsTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + Subscription.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") @@ -1251,6 +1257,9 @@ internal class SubscriptionsTest { .build() ) .netTerms(0L) + .pendingSubscriptionChange( + Subscription.PendingSubscriptionChange.builder().id("id").build() + ) .plan( Plan.builder() .id("id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt new file mode 100644 index 00000000..00fb85f9 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SubscriptionChangeServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeServiceAsync = client.subscriptionChanges() + + val subscriptionChangeFuture = + subscriptionChangeServiceAsync.retrieve( + SubscriptionChangeRetrieveParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + ) + + val subscriptionChange = subscriptionChangeFuture.get() + subscriptionChange.validate() + } + + @Test + fun apply() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeServiceAsync = client.subscriptionChanges() + + val responseFuture = + subscriptionChangeServiceAsync.apply( + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .description("description") + .previouslyCollectedAmount("previously_collected_amount") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun cancel() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeServiceAsync = client.subscriptionChanges() + + val responseFuture = + subscriptionChangeServiceAsync.cancel( + SubscriptionChangeCancelParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 5f1bbf78..10923b97 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -71,7 +71,7 @@ internal class SubscriptionServiceAsyncTest { .amount("10.00") .cadence( SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -243,7 +243,7 @@ internal class SubscriptionServiceAsyncTest { .cadence( SubscriptionCreateParams.ReplacePrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -530,7 +530,7 @@ internal class SubscriptionServiceAsyncTest { .amount("10.00") .cadence( SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -727,7 +727,7 @@ internal class SubscriptionServiceAsyncTest { SubscriptionSchedulePlanChangeParams.AddPrice .AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -898,7 +898,7 @@ internal class SubscriptionServiceAsyncTest { SubscriptionSchedulePlanChangeParams.ReplacePrice .AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt new file mode 100644 index 00000000..97151c51 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.SubscriptionChangeApplyParams +import com.withorb.api.models.SubscriptionChangeCancelParams +import com.withorb.api.models.SubscriptionChangeRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SubscriptionChangeServiceTest { + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeService = client.subscriptionChanges() + + val subscriptionChange = + subscriptionChangeService.retrieve( + SubscriptionChangeRetrieveParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + ) + + subscriptionChange.validate() + } + + @Test + fun apply() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeService = client.subscriptionChanges() + + val response = + subscriptionChangeService.apply( + SubscriptionChangeApplyParams.builder() + .subscriptionChangeId("subscription_change_id") + .description("description") + .previouslyCollectedAmount("previously_collected_amount") + .build() + ) + + response.validate() + } + + @Test + fun cancel() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionChangeService = client.subscriptionChanges() + + val response = + subscriptionChangeService.cancel( + SubscriptionChangeCancelParams.builder() + .subscriptionChangeId("subscription_change_id") + .build() + ) + + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 50acde83..cccf8e7e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -71,7 +71,7 @@ internal class SubscriptionServiceTest { .amount("10.00") .cadence( SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -243,7 +243,7 @@ internal class SubscriptionServiceTest { .cadence( SubscriptionCreateParams.ReplacePrice.AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -522,7 +522,7 @@ internal class SubscriptionServiceTest { .amount("10.00") .cadence( SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -718,7 +718,7 @@ internal class SubscriptionServiceTest { SubscriptionSchedulePlanChangeParams.AddPrice .AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true) @@ -889,7 +889,7 @@ internal class SubscriptionServiceTest { SubscriptionSchedulePlanChangeParams.ReplacePrice .AllocationPrice .Cadence - .ONE_TIME + .MONTHLY ) .currency("USD") .expiresAtEndOfCadence(true)